MIDI problems with PWM audio generator

Hi..

I'm struggling with something - I'm working on an Arduino oscillator.. I'm using Adrian Freed's audio generator code (Arduino sketch for high frequency precision sine wave tone sound synthesis | Adrian Freed

I'm not sure if it's because the interrupt is hogging resources, but I can't seem to receive any MIDI data at the serial port..

I'm using the MIDI library - i've tried parsing MIDI.read in the main loop - and it doesn't work. I also tried it from within the interrupt, and even tried a counter that calls MIDI.read every 'x' number of cycles so the serial buffer has time to fill up, but it's no good.

Does anyone know a way to fix it? Perhaps I need to set up a separate interrupt just for MIDI - I know the audio code uses TIMER2, but I don't know how to make another interrupt..

Any thoughts would be greatly appreciated, I'm pulling my hair out!

Carl

While unfortunately I don't know what is wrong, this might help you from barking up the wrong tree:-

Perhaps I need to set up a separate interrupt just for MIDI -

No the MIDI has it's own interrupt that is from the UART and nothing to do with timers.

It could be that the audio generator is spending too long in its Interrupt Service Routine to allow enough time for the serial to catch everything. Are you getting some data back through the MIDI channel even if it is incomplete?

I just tried disabling the interrupt and the MIDI works fine.. Guess I'll have to look at trimming back the interrupt code.. Unless there's a way to buffer the serial data from within the interrupt and check that?

Posting the code might help too.