Compatibility between Wavetable-Synthesis and teensy audio library

Status
Not open for further replies.
I have been using Wavetable-Synthesis for a project and it seems to have broke with the recent update.

It looks like large parts of it have been incorporated into the teensy audio library (in synth_wavetable.[h/cpp], but in a way that conflicts with the Wavetable-Synthesis. Also, previously converted sound font files don't work anymore and how to convert them does not seem immediate.

I do not see a new import tool with the teensy audio library either.

Any idea on how to get things working again?

Thanks!
 
I must have been posting at the same time as your post...just see it now.

We may have come across the same problem.....my post was about the output from the windows pre compiles sf2 decoder.exe not being compatible with 1.44 release run on arduino 1.8.7......
There is a change to the data structure.......I find 1.44 beta2 with some edits works...?????

What versions and files/ sketches are you using...???
 
Any idea on how to get things working again?

A quick fix to keep using the old code would involve deleting synth_wavetable.cpp and synth_wavetable.h, and edit Audio.h to no longer include synth_wavetable.h.

Unfortunately the original code had many global symbols, some using rather common names likely to conflict with other code. To bring it into the library, those had to change.
 
I just went through your post again and it does seem like the same problem. There were a bunch of naming changes at some point it seems.
I tested this with teensyduino 1.44

After a lot of work I got it to work. I'm using the python version from git (on a Mac), hosted here https://github.com/TeensyAudio/Wavetable-Synthesis
Might try updating the code at some point this week when I have some time, as I also found that I need to cut the RELEASE_COUNT by a factor of 6 as letting go of the piano key had too much sustain

Requires adding AudioSynthWavetable:: to the following in the cpp and h file produced by the sf2 decoder (hope I didn't miss any)

sample_data
instrument_data
SAMPLES_PER_MSEC
ENVELOPE_PERIOD
UNITY_GAIN
LFO_PERIOD

Also requires changing

CENTS_SHIFT => WAVETABLE_CENTS_SHIFT
NOTE => WAVETABLE_NOTE_TO_FREQUENCY
DECIBEL_SHIFT => WAVETABLE_DECIBEL_SHIFT
 
I also think that under the get_timecents_value function in the same file it should read

val = gen.cents * 100.0 if gen else default

instead of

val = gen.cents * 1000.0 if gen else default


matches what I would expect cents to mean and decay time sounds correct now
 
thanks for the decoder. assume it needs to be run on python 3.6. tried on laptop with Lubuntu 18.04 which has Python 3.6 included, so ran the sf2utils install and then tried to run the decoder but get errors sf2utils not found...???? as below


lub18@lub18-3000-C200:~$ pip install sf2utils
Collecting sf2utils
Using cached https://files.pythonhosted.org/pack...5db81440b/sf2utils-0.9.0-py2.py3-none-any.whl
Installing collected packages: sf2utils
Successfully installed sf2utils-0.9.0

File "./SoundfontDecoder-master/decoder.py", line 28, in <module>
from sf2utils.sf2parse import Sf2File
ModuleNotFoundError: No module named 'sf2utils'
 
Thanks, seem to work, will test farther tomorrow (had a busy weekend).

The one comment, is that I think that my comment regarding using 100 instead of 1000 in get_timecents_value still holds.
Basing subjectively on how the piano sounds as well as objectively on how FluidSynth plays the same sound font.

The note just carries on for way too long when letting go of a key otherwise.

On anther note, is there a simple way to load the instrument from SD card instead of memory? (would allow switching instruments when each on barely fits in memory).

Thanks
 
Yes, got it to work, on a Win10, python3.6.6.....my lubuntu setup just needs sorted sometime, thanks
 
Everything runs and plays now, the problem is that it does not play correctly. The amplitude decays incorrectly. I attached the output from the WavetableSynth (left) and Fluidsynth (right), both for middle C on the same sound font file, plot is of waveform in dB

Any ideas where to start to correct this or if there is a better place to inquire?

Thanks

Screenshot 2018-10-04 13.07.26.jpg
 
Left: I'd say, it's exponential - might be intended?
Right: Fluidsynth does not look very healty, too.. :)
 
Just to clearup my earlier post..........Paul's new Decoder works OK on Lubuntu 18.04 and Python3.6......use ..... pip3 install sf2utils .... to install the utilities
and ...... python3 controller.py ...... to run the decoder GUI.
 
Left: I'd say, it's exponential - might be intended?
Right: Fluidsynth does not look very healty, too.. :)

I dug deeper

1. had a look at mac's garage band, different instrument, but also shows similar behavior to fluidsynth
2. BTW, fluidsynth and garage band show an exponential decay behavior (linear in dB domain), the behavior of synth wavetable is linear in the amplitude domain (logarithmic in dB domain)

For decay, which is attenuation driven, physics describe an exponential decay behavior: exp(-at)

I started looking into fixing the code and ran into this comment:

Code:
	// Definitions of the states generally follow the SoundFont spec, with a major exception being that all
	// volume scaling is linear realtive to amplitude; this is correct with respect to the attack, but not
	// the correct implementation relative to the decay and release which should be scaling linearly relative
	// to centibels. Practically this means the decay and release happen too slowing intially, and too quick
	// near the end

Looking to see what else I can do to the code
 
I modified the library to do exponential attenuation on Delay and Release per the Soundfont spec.

Modified code can be found in my fork of the Audio library in case there is interest in pulling it into mainline or someone else wants to use it (not sure how to suggest a change to the library officially, don't work with GitHub much)
https://github.com/laughingrice/Audio

Doing proper exponential attenuation is probably to computationally intensive, so I did a 10 stop linear spline approximation instead, should add very little overhead.
Output looks and sounds much more like I would expect now, first signal is the results of holding the key, second one is a key press and immediate release.

Next target is to see how to handle a stereo sound font, although it looks like most midi players also add an envelope modulation as seen in the fluid synth output that I need to look into at some point as well

Screenshot 2018-10-10 16.44.46.png
 
Last edited:
Looks like I just ran into the same problem with the Teensy 1.45 release - the SoundFontDecoder.exe program doesn't seem to add the required "AudioSynthWavetable::" to the generated .cpp/.h files
I guess that hasn't been updated to match the Python source files yet?
 
Sorry to bump an old thread, but I'm finding some confusion in using Paul's updated decoder.py script. Granted, I am totally new to Python. I installed the latest version, 3.7, but I can't seem to get the script to run. I'm getting a syntax error when it tries. All I'd really like to do is convert some Soundfounts to use with my Teensy project. The basicflute that comes with it sounds great, but I'd love to try out the other instruments. Any assistance would be much appreciated!
 
Status
Not open for further replies.
Back
Top