Guest

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

MATLAB-Tool for Bandlimited Wavetables
September 8, 2015
12:14 am
Frodson
Member
Members
Forum Posts: 40
Member Since:
September 7, 2015
Offline

Hey Guys,
I wrote a neat little MATLAB-script, which does the following:

- you give it an explicit function you want to use as an wavetable-osc (or rather a cycle of it.)
- MATLAB does fourrier-analysis of said function and finds the coefficients for the sums of sin and cos functions in 'createWavetables()' (synthbook)
- it then outputs these coefficients in a .txt file in an array in C++ syntax.

All you have to do then is to copy said array to your C++ code and modify the createWavetables() function so it uses these coefficients.
In its original version it looks something like this:

for(int i = 0; i < WT_LENGTH; i++) // LOOP THROUGH THE TABLE
{
for(int g = 1; g<=nHarms; g++) // LOOP THOUGH OVERTONES
{
pSawTable[i] += pow((float)-1,(float)(g+1))*(1/n*sigma*sin(2*pi*i*n/WT_LENGTH));
}
}

Where you have to change the accumulation for this:

pCustomTable[i] += customTableOdd[g]*sin(2*pi*double(i)*double(g)/WT_LENGTH) + customTableEven[g]*cos(2*pi*double(i)*double(g)/WT_LENGTH);

where customTableOdd[] and customTableEven[] are the coefficient arrays for the sine and cosine functions.
Note that you need sine as well as cosine functions to recreate waveforms which are neither centrosymmetrically nor axissymmetrically.

And there you have it: An oscillator wich gives you the best approximation of your waveform without any aliasing!
You need MATLAB however. (I don't know whether or not this is used by the community!?)
Cheers Frodson

edit: here's the .m file:
is there any way to attach files in the forum?

September 8, 2015
12:38 am
W Pirkle
Forum Posts: 247
Member Since:
January 29, 2017
Offline

Hi Frodson

Cool, thanks for letting us know about your MATLAB tool! And, yes all of my students are MATLAB-competent so maybe I can get some of them to use this for a project this semester.

Could you give an example of the tool being used?

All the best,

Will

PS: no, can't attach files right now; we did have a SimplePress plugin for a better text editor, but it had too many problems with not letting people reply, so I removed it -- might go back and reinvestigate this now.

September 16, 2015
12:35 am
Frodson
Member
Members
Forum Posts: 40
Member Since:
September 7, 2015
Offline

Hi Will,
here's a simple mono oscillator plugin with four waveforms, featuring:

- Fatsaw
- a composition of 3 parabolas
- sectionwise Noise/Saw
- 16 stages of Sample&Hold

I wonder why it tourned out so big (15Mb)?
Greetings, Frodson

September 16, 2015
10:02 pm
W Pirkle
Forum Posts: 247
Member Since:
January 29, 2017
Offline

Thanks for the sample DLL, Frodson.

The reason the file is 15MB is because it is linked to a library (.lib) file that allows the DLL to run as RAFX and VST2 and VST3 plugins at the same time. Without that library, the plugin would be very small (a few KB). The name of the lib is Sock2VST3 and you can find a bunch of different versions of it in your project folder.

- Will

Forum Timezone: America/New_York

Most Users Ever Online: 36

Currently Online:
6 Guest(s)

1 Guest(s)

Top Posters:

Skyler: 48

Derek: 46

Peter: 41

Frodson: 40

clau_ste: 39

Gwen: 32

JimmyM: 30

TheSmile: 27

EZB: 24

lppier: 23

Member Stats:

Guest Posters: 1

Members: 522

Moderators: 1

Forum Stats:

Groups: 11

Forums: 31

Topics: 545

Posts: 2134