Please consider registering

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 Topic RSS sp_TopicIcon
NanoSynth OSC - read access violation when testing WTOscillator
May 4, 2020 - 12:43 pm
Member Since: May 4, 2020
Forum Posts: 3
sp_UserOfflineSmall Offline


First off, thanks for the book, I'm really enjoying working my way through it!

I've been following along and typing out the code myself, and I've got the NanoSynth working with the Quasi Bandlimited Oscillators no problem, but I've run into an issue when I try to test the Wavetable Oscillators.

So the only change I'm making is to comment out the declarations for the CQBLimitedOscillators and replacing them with CWTOscillator declarations in NanoSynth.h:

// Add your code here: ----------------------------------------------------------- //
// --- our two oscillators
//CQBLimitedOscillator m_Osc1;
//CQBLimitedOscillator m_Osc2;
CWTOscillator m_Osc1;
CWTOscillator m_Osc2;

When I rebuild and run the plugin in RackAFX 6, the sine oscillator only produces a clicking sound and when I change to any of the other waveforms RackAFX crashes and disappears as soon as I play a note.

When I try this while debugging, Visual Studio (I'm using 2017) throws a read access violation exception on this line:

// interpolate the output
dOut = dLinTerp(0, 1, m_pCurrentTable[nReadIndex], m_pCurrentTable[nReadIndexNext], fFrac);

I've tried following the nReadIndex through the code to see if I can find any errors but nothing seems to stand out.

I've also tried downloading the synth projects from this website and doing the same as above on the NanoSynth OSC project and I get the same issue.

Any ideas what's happening here? Have I missed something or is this a known issue?



W Pirkle
May 5, 2020 - 10:50 am
Member Since: January 29, 2017
Forum Posts: 462
sp_UserOfflineSmall Offline

My guess is that the WTOscillators are not getting initialized properly, though I am not sure how that is happening. It sounds like you are using the first NanoSynth, which is pre-modulation matrix?

When you are debugging and look at the this pointer for the WTOscillator object, does everything look good? Index values, sample rate, etc...?


May 5, 2020 - 4:19 pm
Member Since: May 4, 2020
Forum Posts: 3
sp_UserOfflineSmall Offline

I found and fixed the bug!

It's in the CWTOscillator::setSampleRate() method - it checks for a change to the sample rate but because the m_dSampleRate member variable is inherited from COscillator, whose constructor sets it to the default of 44100Hz, is already set to the same value passed in by CNanoSynth's prepareToPlay() method, the check is false and createWaveTables() is never called so the tables are never populated!

Here are the changes I made to fix it:

void CWTOscillator::setSampleRate(double dFs)
// test for change
bool bNewSR = m_dSampleRate != dFs ? true : false;

// --- base class first

// --- recreate the tables only if sample rate has changed
if (bNewSR)
// --- then recreate





I'm surprised no-one else has come across this...

Thanks for helping to point me in the right direction.

May 5, 2020 - 4:28 pm
Member Since: May 4, 2020
Forum Posts: 3
sp_UserOfflineSmall Offline

And yes, it is the pre-modulation matrix version of the NanoSynth.

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
151 Guest(s)

Currently Browsing this Page:
2 Guest(s)

Top Posters:

Skyler: 48

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

clau_ste: 39

JimmyM: 33

Gwen: 32

EZB: 24

lppier: 23

Member Stats:

Guest Posters: 1

Members: 632

Moderators: 1

Admins: 4

Forum Stats:

Groups: 13

Forums: 40

Topics: 667

Posts: 2597

Newest Members:

VariableCook, Henry, Adekoya Adams, WillAMR, weedshop, Gennaro Schiano, HOA, sanketVxT, sem1307, djd_oz

Moderators: W Pirkle: 462

Administrators: Tom: 74, JD Young: 80, Will Pirkle: 0, W Pirkle: 462