electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
STM32F746G Discovery Board from STmicroelectronics
Post new topic   Reply to topic Moderators: State Machine
Page 4 of 5 [122 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
BobTheDog



Joined: Feb 28, 2005
Posts: 4044
Location: England
Audio files: 32
G2 patch files: 15

PostPosted: Fri Oct 20, 2017 10:40 pm    Post subject: Reply with quote  Mark this post and the followings unread

Good stuff.

That is a good milestone Smile
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Oct 21, 2017 2:06 pm    Post subject: Reply with quote  Mark this post and the followings unread

And another milestone - it's a polysynth now. Computed sines (not tables). I had set it for 16 voices, but my oxygen 25 controller doesn't output more than 10 note on messages. If 10 keys are held down, any new keypresses are ignored. I will have to test with a MIDI sequencer.

As a rough metric for how much CPU the synth is using, I have LED 1 (green) turn on while it's in the idle loop (where the MIDI controller lives) and it's turned off by the synth process. The longer the synth process takes to execute (i.e. more voices playing) the dimmer the green LED gets. It's noticable, but it's still rather bright. I can probably scope the LED to see what the on/off ratio is. There were no problems with the sound while doing this, so it looks pretty good. Obviously more features will slow it down, this is a rather featureless synth.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
BobTheDog



Joined: Feb 28, 2005
Posts: 4044
Location: England
Audio files: 32
G2 patch files: 15

PostPosted: Sat Oct 21, 2017 10:21 pm    Post subject: Reply with quote  Mark this post and the followings unread

Good stuff Smile
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Tue Oct 24, 2017 9:17 am    Post subject: Reply with quote  Mark this post and the followings unread

Something I learned today...

Accidentally using a double data type can be devastating to performance. I converted my computed sine organ to one that uses a sine table and linear interpolation to provide precise tuning. I accidentally forgot to include 'f' at the end of a float constant and the performance of the program went into the toilet (it did only 6 voices without crashing the synth).

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
BobTheDog



Joined: Feb 28, 2005
Posts: 4044
Location: England
Audio files: 32
G2 patch files: 15

PostPosted: Tue Oct 24, 2017 10:43 am    Post subject: Reply with quote  Mark this post and the followings unread

There is a compiler flag to force floating literals to float rather than the default double, well worth using: -fsingle-precision-constant
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Tue Oct 24, 2017 12:57 pm    Post subject: Reply with quote  Mark this post and the followings unread

BobTheDog wrote:
There is a compiler flag to force floating literals to float rather than the default double, well worth using: -fsingle-precision-constant


Yes, I know that works. I've got a thing about depending on any default conditions whether they are set by the compiler's internal defaults or ones I add with flags. I'd rather follow this rule an old doctor told me:

Never assume - Always be specific.

If I code with absolute specificity, I can then know what each literal type is - because it's explicit. For me, it's easier/better to see it in the code.

Using such a flag causes the code to look wrong, that is, we C programmers should know that unsuffixed literals like 1.4 are double. When such a flag is used, the 1.4 is float which would eventually confuse. This becomes especially important when looking at someone else's code - where you are pretty much forced to dig around in a makefile which is often not very friendly as well as downright ugly, especially when created by a project generator. I try not to use compiler flags to fix bad code I write. In my case, this problem was corrected by simply adding a single 'f' character to main.c. But as usual, different strokes for different folks.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
BobTheDog



Joined: Feb 28, 2005
Posts: 4044
Location: England
Audio files: 32
G2 patch files: 15

PostPosted: Tue Oct 24, 2017 10:19 pm    Post subject: Reply with quote  Mark this post and the followings unread

The thing is it isn't bad code, for me it is a bad part of the language. In a strongly typed language such as C floating literals in my eye should be sized to destination variable size.

so:

float fValue = 0.0;

The literal should be a float not a double.

double dValue = 0.0;

The literal should be a double.

I know the compiler flag doesn't fix this but at least it fixes the problem when your FPU is only 32 bits and using doubles forces everything into software.

But as you say different strokes.
Back to top
View user's profile Send private message
emeb



Joined: Dec 16, 2008
Posts: 35
Location: Arizona

PostPosted: Tue Oct 24, 2017 11:36 pm    Post subject: Reply with quote  Mark this post and the followings unread

Nice to see you're making lots of progress with this. I've been coding on F7 for the last few months for some commercial projects in synth and it's working fairly well. One of the designs is running an F746 at full clock rate and I'm able to get about 32 oscillators with some fairly complex waveform calculations going simultaneously (along with all the modulation controls and a GUI).

It's not as easy to go big as when you're using a PC or RPi / etc. so you do have to work at optimization - take advantage of ITCM and DTCM to accelerate processor cycles and memory access, use DMA wherever possible, shut down stuff you're not using to conserve bus cycles, etc. Quite a brain teaser...
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Wed Oct 25, 2017 4:10 am    Post subject: Reply with quote  Mark this post and the followings unread

Very familiar stuff there emeb. Yesterday I worked on converting my computed sine organ to wavetable with linear interpolation. The computed sine synth was able to implement 17 voices while the wavetable version implements 33. My MIDI connection is via USART6 which I operate in "bare-metal" mode. SysTick timer is disabled which was a challenge since the original driver code needed SysTick for some delays it used during initialization of the CODEC. I'm also running the CPU at 216 MHz. This is pretty much featureless. With a single pole IIR low pass filter for click removal, the voice count drops to 31. And then of course, I find optimizations and it's back to 32 voices with the click filter enabled.

As for numerical literals, even though C doesn't force us to always suffix identifier names, I do it anyway. It is obvious to a human reader and the compiler can't do what a human might not expect.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Nov 04, 2017 6:08 am    Post subject: Reply with quote  Mark this post and the followings unread

I've now got a Karplus-Strong MIDI polysynth working. At present, the features are sparse including precise tuning and sustain, but no pitch bend yet. As such, the synth supports 28 voices.

I've been looking at the driver code for inefficiencies. The audio driver includes callbacks to allow filling the DMA buffers with new data. I've never liked callbacks because they burn call/return clocks, so I'm looking to see if I can eliminate the callbacks and use the ISR directly. I know it's only a few clocks, but every clock helps. Of course, there is the standard DO NOT EDIT THIS FILE...

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Thu Nov 09, 2017 9:04 am    Post subject: Reply with quote  Mark this post and the followings unread

I had been wondering recently what the performance difference between float and int32_t would be so I wrote a very simple benchmark to test adds. I ran the test with the FPU enabled and disabled.

With all CPU caches disabled:
With FPU enabled, float types take about 3.8% longer than int32_t to do an add.
With FPU disabled, float types take about 72 times longer than int32_t to do an add.

With all CPU caches enabled:
With FPU enabled, float and int32_t types take nearly the same amount of time within about 0.1%. Some tests line items show float a bit faster, some show int32_t a bit faster.

The above tests were done with a loop of 100,000,000 iterations.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
emeb



Joined: Dec 16, 2008
Posts: 35
Location: Arizona

PostPosted: Fri Nov 10, 2017 8:36 am    Post subject: Reply with quote  Mark this post and the followings unread

Nice research there. It's not immediately obvious to me why turning the cache on makes float math equal int math. Will have to think on that some...
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Tue Nov 14, 2017 11:17 am    Post subject: Reply with quote  Mark this post and the followings unread

More about my benchmark test:

On a whim, I decided to test using firmware version 1.4.0 and 1.8.0. Ultimately, there is no difference due to the firmware, but the two programs (identical C code) used different makefiles. It turned out that 1.4.0 used a different optimization level than the 1.8.0.

Here: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html I found great information on using gcc optimization and I was able to get all of the numbers to match for both test environments.

The reason I turned to optimization is that the loop times as well as the float and int32_t add times were quite a bit larger (more than 4 times slower) when optimization was default.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Tue Nov 14, 2017 2:44 pm    Post subject: Reply with quote  Mark this post and the followings unread

Testing the new optimization effect on my Karplus-Strong poly synth - with default optimization, the synth would support 7 voices (under high stress conditions). With optimizations set to full, the voice count increased to 30. This (rather roughly) confirms that given a task with heavy arithmetic, with default optimizations, the STM32F746 runs about 4 times slower than with full.

It supports precision tuning, CC control over timbre, pitch bend to +12/-12 semitones and sustain. I will probably drop the voice count to 16 (or 24) to allow for chorus.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Wed Nov 15, 2017 2:14 pm    Post subject: Reply with quote  Mark this post and the followings unread

Now a question:

I've been working on getting peak performance out of the STM32F746. One thing that seems to escape me is how to get gcc to use the DSP instructions. By using arm-none-eabi-objdump -d -S main.o I can get an assembly listing and it's clear that no DSP instructions are being used. The project contains 2 single pole IIR filters which should be able to use a vmla.f32 instruction, but it does not appear in the listing.

So the question is:
Is there a gcc option flag that I need to use to get gcc to use DSP instructions?

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
emeb



Joined: Dec 16, 2008
Posts: 35
Location: Arizona

PostPosted: Thu Nov 16, 2017 9:18 am    Post subject: Reply with quote  Mark this post and the followings unread

JovianPyx wrote:
Now a question:Is there a gcc option flag that I need to use to get gcc to use DSP instructions?


None that I've found. Generally gcc is pretty good about writing efficient code and doing smart things with optimization such as loop unrolling and taking advantage of pipelining. That said, it doesn't seem to always take advantage of the extra DSP instructions. For example, I've seen it use the integer multiply/accumulate instructions but it doesn't appear to properly infer the saturation operation. When I need saturation I often just use inline assembly to force it to use those.

You should take a look at some of the "intrinsic" functions in the CMSIS library - these are the DSP instructions wrapped up to look like inline C functions that you can slap down when you know they apply. Sometimes that helps, but more often than not I've found that there's not much to be gained.

Optimization is a dark art...
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Thu Nov 16, 2017 9:58 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks emeb,

Ok, that's just the way it is then. I'll first look at the DSP library, but I'll probably take a crack at writing my own filter with __asm just for "fun". All I need is a simple single pole low pass IIR filter. I've done it with the DSP instructions on a dsPIC in assembly language, so hopefully, I can make it happen with the STM32F746. For now though, the other optimization I've done gives at least acceptable performance. The DSP instructions won't double the voice count to be sure, but they may free up clocks I can use for various new features I'd like to add.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Fri Nov 17, 2017 5:47 pm    Post subject: Reply with quote  Mark this post and the followings unread

emeb wrote:
You should take a look at some of the "intrinsic" functions in the CMSIS library - these are the DSP instructions wrapped up to look like inline C functions that you can slap down when you know they apply. Sometimes that helps, but more often than not I've found that there's not much to be gained.

Optimization is a dark art...


I've been looking at the DSP library and now I wonder - is this just a set of well written C functions or do they actually cause gcc to insert instructions like vmla.f32 or vfma.f32? There seems nothing special in the code.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
emeb



Joined: Dec 16, 2008
Posts: 35
Location: Arizona

PostPosted: Sat Nov 18, 2017 5:53 pm    Post subject: Reply with quote  Mark this post and the followings unread

The CMSIS DSP library doesn't have any special directives to force the use of certain instructions - it is as you surmise just a set of well written DSP functions. One might even debate how well written it is - it makes certain assumption about pipelining etc that may not apply across the whole Cortex Mx family.

When I mentioned "intrinsics" above I was specifically talking about the static inline functions defined in cmsis_gcc.h which allow you to access special CPU instructions as though they were actual C functions.
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Nov 18, 2017 6:29 pm    Post subject: Reply with quote  Mark this post and the followings unread

emeb wrote:
The CMSIS DSP library doesn't have any special directives to force the use of certain instructions - it is as you surmise just a set of well written DSP functions. One might even debate how well written it is - it makes certain assumption about pipelining etc that may not apply across the whole Cortex Mx family.

When I mentioned "intrinsics" above I was specifically talking about the static inline functions defined in cmsis_gcc.h which allow you to access special CPU instructions as though they were actual C functions.


OH... thanks, I shall take a special look there.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Fri Dec 08, 2017 4:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

Have a listen, this is a "drone" using 2 Karplus-Strong strings with the sustain pedal held down. The recording is completely dry, there are no special effects. The 2 strings are a musical fifth apart and are struck at regular intervals with a small delay between one and the other.

This is being done with a 16 voice version, tho only a very few voices are being used.


KS Drone 1.mp3
 Description:
KS Drone 1

Download
 Filename:  KS Drone 1.mp3
 Filesize:  6.13 MB
 Downloaded:  674 Time(s)


_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Dec 09, 2017 4:04 pm    Post subject: Reply with quote  Mark this post and the followings unread

Now that it's working properly, I've recorded Carol of the Bells composed by Mykola Leontovych. It's a lovely piece for this time of year too.

It is played on a Karplus-Strong physical model of a string with a kind of distortion or wave-shaping on each string. The technique adds second harmonic.

The sound was the result of lots of tweaking of the instruments 5 timbre parameters (they are recognized as continuous controller values). The sustain pedal is held down throughout the piece.


Carol_of_the_Bells.mp3
 Description:
Carol of the Bells played on a 16 voice Karplus-Strong polysynth

Download
 Filename:  Carol_of_the_Bells.mp3
 Filesize:  1.17 MB
 Downloaded:  716 Time(s)


_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Dec 09, 2017 5:22 pm    Post subject: Reply with quote  Mark this post and the followings unread

another version toned down a bit, less feedback and less loop filter bandwidth


Carol_of_the_Bells.mp3
 Description:
Carol of the Bells

Download
 Filename:  Carol_of_the_Bells.mp3
 Filesize:  1.19 MB
 Downloaded:  666 Time(s)


_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Sat Dec 09, 2017 5:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

Sounds good Scott, the distortion may a bit over done .. well .. to my current taste .. which may be different tomorrow .. the second version seems to have some more dynamics to me .. and overall, a good KS implementation!
_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Dec 09, 2017 6:52 pm    Post subject: Reply with quote  Mark this post and the followings unread

Yeah, overdone a bit. I've reduced the distortion and also the loop filter and linear decay (sustain) and it sounds better now.

Should I delete the others?


Carol_of_the_Bells.mp3
 Description:
Carol of the Bells

Download
 Filename:  Carol_of_the_Bells.mp3
 Filesize:  1.17 MB
 Downloaded:  683 Time(s)


_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: State Machine
Page 4 of 5 [122 Posts]
View unread posts
View new posts in the last week
Goto page: Previous 1, 2, 3, 4, 5 Next
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use