<p>I need to implement a <a href="http://en.wikipedia.org/wiki/Wavetable" rel="nofollow noreferrer">wavetable synthesizer</a> in an ARM Cortex-M3 core. I'm looking for any code or tools to help me get started.</p>

<p>I'm aware of <a href="http://elm-chan.org/works/mxb/report.html" rel="nofollow noreferrer">this AVR implementation</a>. I actually converted it to a PIC a while back. Now I am looking for something similar, but a little better sounding.</p>

<p>ANSI C code would be great. Any code snippets (C or C++), samples, tools, or just general information would be greatly appreciated.</p>

<p>Thanks.</p>

[{'answer_id': 30452, 'author': 'Nick Haddad', 'author_id': 2813, 'author_profile': 'https://Stackoverflow.com/users/2813', 'pm_score': 4, 'selected': True, 'text': '<p>The Synthesis Toolkit (STK) is excellent, but it is C++ only:</p>\n\n<p><a href="http://ccrma.stanford.edu/software/stk/" rel="noreferrer">http://ccrma.stanford.edu/software/stk/</a></p>\n\n<p>You may be able to extract the wavetable synthesizer code from the STK though.</p>\n'}, {'answer_id': 81220, 'author': 'CL.', 'author_id': 11654, 'author_profile': 'https://Stackoverflow.com/users/11654', 'pm_score': 2, 'selected': False, 'text': '<p>Two open-source wavetable synthesizers are <a href="http://sourceforge.net/projects/fluidsynth/" rel="nofollow noreferrer">FluidSynth</a> and <a href="http://timidity.sourceforge.net/" rel="nofollow noreferrer">TiMidity</a>.</p>\n'}, {'answer_id': 48247220, 'author': 'LifeInTheTrees', 'author_id': 2040877, 'author_profile': 'https://Stackoverflow.com/users/2040877', 'pm_score': 0, 'selected': False, 'text': "<p>Any ARM synth, the best ones, can be changed to wavescanner in less than a day. Scanning the wave from files or generating them mathematically is nearly the same thing audio wise, WT provides massive banks of waveforms at zero processing cost, you need the waves, the WT oscillator code itself is 20 lines. so change your waveform knob from 3 to 100 to indicate which WAV you are reading, use a ramp/counter to read the WAV files(as arrays). WT fixed. </p>\n\n<p>From 7 years of Synth experience, i'd recommend to change 20 lines of the oscillator function of your favorite synth to adapt it to read wave arrays. The WT only uses 20 lines of logic, the rest of the synthesizer is more important: LFO's, Filters, input parameters, preset memory... Use your favorite synth instead and find a WT wave library as WAV files and folders, and replace your fav synth oscillators with WT functions, it will sound almost the same, only lower processing costs.  </p>\n\n<p>A synth normally uses Sin, Sqr, Saw, Antialiased OSC functions for the wave... </p>\n\n<p>A wavetable synth uses about 20 lines of code at it's base, and 10/20/100ds of waves, each wave sampled at every octave ideally. If you can get a wavetable sound library, the synth just loops, pitch shifts, the sounds, and pro synths can also have multiple octave to mix the octaves. </p>\n\n<p>WTfunction = </p>\n\n<ul>\n<li>load WAV files into N arrays</li>\n<li>change waveform = select waveform array from WAV list</li>\n<li>read waveform array at desired Hz </li>\n</ul>\n\n<p>wavescanner function =</p>\n\n<ul>\n<li>crossfade between 2 waves and assign xfade to LFO, i.e. sine and xfade.</li>\n</ul>\n\n<p>The envelope, filter, amplitude, all other functions are independent from the wave generation function in all synths. </p>\n\n<p>remember the the most powerful psychoacoustic tool for synthesizers is deviation from the digital tone of the notes, it's called unison detune, sonic character of synthesizers mostly comes from chorus and unison detune. </p>\n\n<p>WT's are either single periods of waves of longer sections, in more advanced synths. the single period stuff is super easy to write into code. the advanced WT's are sampled per octave with waves lasting N periods, even 2-3 seconds, i.e. piano, and that means that they change sound quality through the octaves, so the complex WT's are crossfaded every octave with multiple octave recordings. </p>\n"}]
['https://Stackoverflow.com/questions/29665', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3175/']