Pages: [1]   Go Down
Author Topic: MIDI problems with PWM audio generator  (Read 746 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi..

I'm struggling with something - I'm working on an Arduino oscillator.. I'm using Adrian Freed's audio generator code (http://adrianfreed.com/content/arduino-sketch-high-frequency-precision-sine-wave-tone-sound-synthesis

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 597
Posts: 33301
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

While unfortunately I don't know what is wrong, this might help you from barking up the wrong tree:-
Quote
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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1328
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 Posting the code might help too.
Logged


Pages: [1]   Go Up
Jump to: