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
MIDI and Audio
No permission to create posts
September 12, 2013
9:40 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hi Will,

i managed to play the wavetable oscillator from your book via MIDI Keyboard by trial and error with the MIDI Routines. But I have a lot of latency (ca. 1 sec.) So my question: What is the correct handling of the Midi Note On/Off Routines for the user? And second q.:
Does RackAFX use the standart Windows Audio Drivers (DirectX) or can I use it with ASIO ??

Thanks in advance and many many thanks for your great book!

Peter

September 13, 2013
2:12 am
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

Hi Peter

Yes, there is latency when rendering (synthesizing) audio whether you use MIDI or not. You can improve this by using the Audio Setup and changing the buffer size to the lowest possible without clicking. And, it does use the standard Windows drivers (WAD) and not ASIO. I had planned on ASIO integration at some point so that is still an option.

I teach a C++ Synth Plug-in class and we usually just deal with the latency during development and debug. When it's time to test final product, we use the "Make VST Compatible" option and turn it into a VST DLL. Then, we can use any client we want; any latency will be due to that client and the MIDI driver for your device; clients like Ableton Live (what I use) and Sonar (what many book readers use) have ultra-low latency and more options for setting it (i.e. in the driver or sometimes in hardware).

For midi note on/off we simply set flags and call a voice allocation function that starts up the oscillators, etc...

Hope that helps!

Will

September 13, 2013
6:27 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hi Will

Audio is clear now, thank you. But let me explain my MIDI Problem:
At the moment I use for MIDI Not on in the WTOscillator.cpp file:

bool __stdcall CWTOscillator::midiNoteOn(UINT uChannel, UINT uMIDINote, UINT uVelocity)
{
m_iMIDI_Note_on = uMIDINote;
reset();
cookFrequency();
m_bNoteOn = true;
return true;
}

What does _stdcall and what UINT mean in this case. Is this the routine called by the operating system (Windows) in case of a MIDI (On) Interrupt delivering the variables uChannel, uMIDINote and uVelocity to the program ?

regards

Peter

September 13, 2013
8:18 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

Hi Peter

Both _stdcall and UINT are explained in my book. _stdcall is a directive dealing with how the stack is cleaned up after a function call. It is there to maximize compatibility with C++ compilers (there was a time when RackAFX supported the CodeBlocks compiler; additionally it tells XCode how to clean the stack if you are doing a Make AU XCode version of your Plug-In). UINT is a typedef for "unsigned integer." In MacOS it is typedef'd UInt32 or UInt16.

All the MIDI messages are routed from the client (RackAFX or a VST client if you are doing Make VST compatible); in other words, the client is always the MIDI message sink and the client routes messages to the plug-in if desired. In VST you have to set a flag to let the client know you want MIDI. In RackAFX, you always get the core MIDI messages (noteOn, noteOff, Pitchbend, ModWheel, MIDI Clock). I decode the MIDI messages (ie channel, status and data bytes) and send them to the plug-in. The noteOn and noteOff functions are just helpers so you don't have to deal with the low level MIDI data - if you want to, set the flag m_bWantAllMIDIMessages = true in your constructor, then you will get all the MIDI messages in the function midiMessage() but its up to you to decode the channel, status and data bytes (delivered as UINTs from 0-127).

- Will

September 14, 2013
3:41 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hi Will,

you are right, _sdtcall and UINT are in the book, but I did not read the chapters completely, sorry for this Cry. Thanks for the answer to the MIDI Routines - this is very helpfull for me.

Last question:
Do you have a favourite algorithm for an (nearly) alias free oscillator ?

regards

Peter

September 14, 2013
5:50 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

HI Peter

Yes, my favorite algorithm right now is PolyBLEP - its amazing. It produces nearly alias free saw, square (with PWM) and hard-sync saw with a simple algorithm. Valimaki has written several articles on it, I think the best one is here:

http://ieeexplore.ieee.org/xpl.....%3D4117934

You can get the algorithm in Python here:

http://www.acoustics.hut.fi/pu.....s/spl-ptr/

Click on the link that says Python Source.

I wrote a C++ function based on that Python code but I made some alterations that might take a lot of explaining. Let me know if you want it but definitely check the source code above first.

- Will

September 15, 2013
9:08 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hi Will

I read the abstract of the Välimäki article, very interesting. Unfortunately I am not a member of IEEE and buying the whole article for 31$ is a little bit expensive. But I found some more explanations in the net.

I checked the Python code. I am not so familiar with Python, but it looks not too complicated. So I am very interested in your C++ function! Is it possible to use any Wavetable with PolyBLEP if you are able to identify the discontinuities and replace them by polynomial approximation ?

regards

Peter

September 15, 2013
10:17 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

Hey Peter

Here is the original BLEP paper (maybe you already have this)

http://www.cs.cmu.edu/~eli/pap.....rdsync.pdf

At the end, it covers the kinds of discontinuities BLEP can help smear over, so there are limitations. Another issue is that you have to know the exact height of the discontinuity a priori; any error in that value will screw up the algorithm. So, this technique is used on mathematically constructed waveforms rather than tables. For bandlimited tables, you wouldn't need it anyway. However, if you are hard-syncing two bandlimited wavetable oscillators, then you would produce discontinuities that BLEP could help fix - the issue is knowing the exact height of the discontinuity; bandlimited tables have "wavy" waveforms in them (my book pp 318-319).

You can get my polyBLEP() function here:

http://www.willpirkle.com/Down.....PolyBLEP.h

The return value is either 0 or a residual; the residual is added to the sample to produce the corrected value. A flag in the argument negates the residual for falling edges so the residual is always added after the function call.

- Will

September 23, 2013
2:19 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hey Will

I tried to implement the PolyBLEP, but nothing changes within the saw waveform. I used the WTOscillator from the Book Chapter 9. Your PolyBLEP function is in the .h file. At the moment only saw is implemented :

case saw:
if(m_uTableMode == normal) // normal
{
fOutSample = m_SawtoothArray[nReadIndex];
if(m_uPolyBLEB == on){
fOutSample += polyBLEP(normModulo, normInc, 1.0, false, bDone, 0.0);
}
etc.

the variables are defined as :
float normModulo = m_fReadIndex/1024;
float normInc = m_fFrequency_Hz/(float)m_nSampleRate;

I do not use the interpolation function, because I am not sure if interpolation after PolyBLEP or PolyBLEP after interpolation is correct.

What did I wrong ???

regards - and again thanks for help!

Peter

September 23, 2013
6:16 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

First make sure you are not using a bandlimited wavetable. The way I setup this polyBLEP is the same as the original in Python expects. Sawtooth edge is 0.0 (which I later translate to 1.0 in the fn) but the wavetables in my book are all calculated to be in phase with each other. So, the saw discontinuity is actually at 0.5 in the modulo count.

- Will

September 23, 2013
11:36 pm
Avatar
Peter
Member
Members
Forum Posts: 41
Member Since:
September 12, 2013
sp_UserOfflineSmall Offline

Hi Will,

The problem was an incorrect conversion from float to double, my mistake - I found it with the debugger. For the inperpolation I will try out what sounds best, my idea is to interpolate everything except for the corrcected discontinuities.

-Peter

Forum Timezone: America/New_York

Most Users Ever Online: 36

Currently Online:
3 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: 476

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 30

Topics: 482

Posts: 1876

Newest Members:

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