Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
MATLAB-Tool for Bandlimited Wavetables
No permission to create posts
September 8, 2015
12:14 am
Avatar
Frodson
Member
Members
Forum Posts: 38
Member Since:
September 7, 2015
sp_UserOfflineSmall 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:
http://s000.tinyupload.com/?file_id=07945699471497871557
is there any way to attach files in the forum?

September 8, 2015
12:38 am
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall 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
Avatar
Frodson
Member
Members
Forum Posts: 38
Member Since:
September 7, 2015
sp_UserOfflineSmall 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

http://s000.tinyupload.com/?fi.....5291524042

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

September 16, 2015
10:02 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall 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:
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Peter: 41

Derek: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 477

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 30

Topics: 483

Posts: 1877

Newest Members:

Jaggxn, sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc

Moderators: W Pirkle: 143

Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 143