Author Topic: waveforms  (Read 19019 times)

matrix12x

  • Team Member
  • ***
  • Posts: 200
    • View Profile
waveforms
« on: June 08, 2014, 03:04:32 AM »
Hi,
I am interested in possibly trying to program one or two more waveforms for the oscillators such as a formant or something. I have bee with the FM8 and really love the way an FM modulated formant sounds.

I was wondering how difficult this would be? I started looking at the code in waveforms.java. Also would there be enough room left for something like this?

Would a good starting point be the Shruthi-1 code in his oscillator.cc file?

Thanks,
John

pld

  • Team member
  • *
  • Posts: 41
    • View Profile
Re: waveforms
« Reply #1 on: June 08, 2014, 09:19:27 AM »
I guess space is an issue if you want to add a waveform, see http://ixox.fr/forum/index.php?topic=63386.0
Otherwise it's not too difficult as long as it's just another lookup-table (check src/synth/Osc.cpp and Osc.h, and SynthState.h and .cpp for the OscShape enum and editing).

If the waveform is generated a runtime somehow, then it becomes a bit more complex :)
The shruti oscillator is a bit different since it's integer based (and avr-optimized) instead of float, but the basic principles are the same (phase accumulator, lookup, interpolation).

matrix12x

  • Team Member
  • ***
  • Posts: 200
    • View Profile
Re: waveforms
« Reply #2 on: June 08, 2014, 04:59:57 PM »
Thanks. That link was great. I started looking at the tables and I see that they are normalized to +/-1 and that the values are float. How does one take a single cycle wave file and create a table of 1024 to 2048 entries from it? I am assuming I would have to start with a raw format file, but is it 8, 16 or 32 bit?

Is there possible a python script? I will definitely start searching.

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2259
    • View Profile
Re: waveforms
« Reply #3 on: June 09, 2014, 10:55:04 AM »
Thanks. That link was great. I started looking at the tables and I see that they are normalized to +/-1 and that the values are float. How does one take a single cycle wave file and create a table of 1024 to 2048 entries from it? I am assuming I would have to start with a raw format file, but is it 8, 16 or 32 bit?

Is there possible a python script? I will definitely start searching.

No there's no python script.. What i do is i create directly the c arrays in java based on some series of sinusoid.
I'm afraid you'll have to find by yourself how to create your own arrays.

The waveforms are in the fast memory access of the STM32F4 (CCM). There's only 64Kb here and almost all is used.
So what you can do is to replace an existing waveforms (keep the sinusoid one for FM ;-).

Or you can add one or two in the regular memory... just remove the "__attribute__ ((section(".ccm")))" in the declaration in the wave.c file..
Will be slower and could produce some audio glitch when access in full polyphony with effects...

Xavier

tIB

  • Team member
  • *
  • Posts: 18
    • View Profile
Re: waveforms
« Reply #4 on: June 09, 2014, 09:30:05 PM »
Forgive me for throwing out ideas that I have no concept of whether they are possible to realise, or the required skills to make them so but...

One of the things I love to do in the analogue world is FM with sine waves ran into wavefolders. I've often wonders what yamaha style 'FM' might sound like with the sine waves animated in this way- pretty amazing I'd have thought! I'd have thought realising that would take a ton of processing power though?

Imagine this sort of thing on 6 operators! https://www.youtube.com/watch?v=vXr01PSF7iw

matrix12x

  • Team Member
  • ***
  • Posts: 200
    • View Profile
Re: waveforms
« Reply #5 on: June 10, 2014, 12:44:18 AM »

No there's no python script.. What i do is i create directly the c arrays in java based on some series of sinusoid.
I'm afraid you'll have to find by yourself how to create your own arrays.

The waveforms are in the fast memory access of the STM32F4 (CCM). There's only 64Kb here and almost all is used.
So what you can do is to replace an existing waveforms (keep the sinusoid one for FM ;-).

Or you can add one or two in the regular memory... just remove the "__attribute__ ((section(".ccm")))" in the declaration in the wave.c file..
Will be slower and could produce some audio glitch when access in full polyphony with effects...

Xavier

Thanks. I have my table now, normalized to +/-1. 1024 values. I am adding them to waves.c, but I have one quick question, do I need to format in 5 rows of equal size like you did? For my first attempt, I am going to load it into regular memory, and see what happens.


matrix12x

  • Team Member
  • ***
  • Posts: 200
    • View Profile
Re: waveforms
« Reply #6 on: June 10, 2014, 02:17:27 AM »
Quick question, what is the tool chain that is required?
I am on OSX.

pld

  • Team member
  • *
  • Posts: 41
    • View Profile
Re: waveforms
« Reply #7 on: June 10, 2014, 07:31:48 AM »
I've been using gcc-arm-none-eabi-4_7-2013q3 on OS X.
IIRC I did a 'brew install dfu-util' to be able to flash the board directly...

pld

  • Team member
  • *
  • Posts: 41
    • View Profile
Re: waveforms
« Reply #8 on: June 10, 2014, 11:10:28 AM »
do I need to format in 5 rows of equal size like you did?
As long as the array has 1024 elements, the formatting shouldn't matter. But it is more readable in case have to re-count :)
How did you come up with the values?

Quote
For my first attempt, I am going to load it into regular memory, and see what happens.
Will be interesting.
If I find some time, I'll compile a debug version and measure the impact in cycles (unless Xavier has already tried that?).

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2259
    • View Profile
Re: waveforms
« Reply #9 on: June 10, 2014, 11:00:21 PM »
Quote
For my first attempt, I am going to load it into regular memory, and see what happens.
Will be interesting.
If I find some time, I'll compile a debug version and measure the impact in cycles (unless Xavier has already tried that?).

The only measure i did (a while back) was that with regular memory i could not get 8 voices (of 6op) at the same time without audio drop out.
Since then, there were a lot of optimization (and i could even add a FX slot).
Don't know what the status is today.
Would be fast to test ;-)
remove "__attribute__ ((section(".ccm")))" from all wavetables and try to get audio glitch.

matrix12x

  • Team Member
  • ***
  • Posts: 200
    • View Profile
Re: waveforms
« Reply #10 on: June 11, 2014, 12:05:53 AM »
I am installing the tool chain right now and should compile tonight. I'll let you know how it goes.

matrix12x

  • Team Member
  • ***
  • Posts: 200
    • View Profile
Re: waveforms
« Reply #11 on: June 11, 2014, 02:54:57 AM »
after some trial and error I got it to compile. I am still getting some errors while compiling, but I still seem to get my bin file, and it installs fine and seems to run fine.

I started with just removing "__attribute__ ((section(".ccm")))" to get the current waveforms to run in regular memory.

How many simultaneous notes should I try and play before expecting a drop out?

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2259
    • View Profile
Re: waveforms
« Reply #12 on: June 11, 2014, 09:15:02 AM »
If you have your bin file what you got are warnings and not errors.  ;)

Worst case scenario :
In the menu set all midi channel to "1" for the 4 instruments.
Set 2 voices per instrument and select algos 27 or 28 and a different FILTER for each.
Then press 2 keys at the same time !

If you remove the CCM attribute for a waveform, for a real test, specify your waveform for all the operators of all instruments.

pld

  • Team member
  • *
  • Posts: 41
    • View Profile
Re: waveforms
« Reply #13 on: June 11, 2014, 09:04:08 PM »
So I just did a quick first test with no waveforms in CCM, algo 27 for each voice, HP filter, arp running and well, it doesn't sound pretty, but no obvious glitching (overclocked firmware).
But its too hot for me so I might have just re-flashed the same firmware twice ;)

matrix12x

  • Team Member
  • ***
  • Posts: 200
    • View Profile
Re: waveforms
« Reply #14 on: June 12, 2014, 03:55:19 AM »
Same here.
overclocked, no waveforms in CCM. no filter. Algo 27 and 28. held down 2 keys.
I did not notice any glitches either.


I started adding my own wave and got this when I compiled. Any ideas?
src/synth/Osc.cpp:108:1: error: too many initializers for 'WaveTable [8]'