Durisian Posted July 10, 2007 Report Posted July 10, 2007 So for my first midibox i'm keeping the hardware side really simply, and getting into the programming side.This is link between my fcb1010 pedal board, and v-amp pro. To add another 8 pedals to it. And lcd displayAnyway,I want to display the bpm the tap tempo function, now at this point it's a very basic design and can't ask the v-amp.It needs to come from the time difference between 2 button presses.Here's the code i've got;void Timer(void) __wparam { bpmcountms = bpmcountms + 1; bpm = 60000 / bpmcountms; //Stop timer if taken too long to press tap button again if (bpm == 40 ) { MIOS_TIMER_Stop(); tapflag = 0; } } --------------------8<--------------- From MPROC_NotifyFoundEvent if( evnt1 == tapcc ) { //is tap tempo cc if (tapflag == 1) { MIOS_TIMER_Stop(); //stop timer is it's running MIOS_LCD_PrintCString(" "); MIOS_LCD_PrintBCD3(bpm); MIOS_LCD_PrintCString(" BPM "); bpmcountms = 0; //reset counters bpm = 0; } tapflag = 1; MIOS_TIMER_Init(0x00, 10000); //start timer };This almost works, except it doesn't display a consistant value for bpm. tapping at a solid 120bpm, results in values from 10 to 200.Any idea what i've done wrong, or perhaps an alternate solution. Quote
audiocommander Posted July 10, 2007 Report Posted July 10, 2007 Hello Durisian,the question is: how are you stopping the timer?If the timer isn't stopped, the bpm gets changed every millisecond, which seems to be the result you are describing.Regards,Michael Quote
Durisian Posted July 10, 2007 Author Report Posted July 10, 2007 thanks ac.Timer is stopped on the 2nd button press (if tapflag==1)And then reset and restarted once it has been displayed.If the bpm falls to 40 (signifiying there will be no more button presses), it also stops.... I think.... ;D Quote
stryd_one Posted July 10, 2007 Report Posted July 10, 2007 MPROC_NotifyFoundEvent Is not interrupt driven, so it is only checked every so often. Also, it checks the bytes recieved against the table to see if they are recognised. This may not be suitable for realtime input. You should use USER_MIDI_NotifyRx, but that is interrupt driven so your code should be fast. Edit: Whoops that doesn't exist in C wrapper... Mayyybe NotifyFoundEvent will be better but I dunno...Better yet, I would use a DIN.Edit: Yeh.USER_SR_Service_* can be used to increment your counter as it is called each 1ms. That will free up a timer.Hope that helps! Quote
Durisian Posted July 10, 2007 Author Report Posted July 10, 2007 Thanks Stryd.There is much more to the code, parts in this function rely on mproc_event_table.I think i'll create a new table in flash memory for overall simpler handling and useability.And then can move the code to MPROC_NotifyReceivedEvntusing a din had crossed my mind, but there are already 10 buttons on the pedal board. I only use 9. seems a little silly to add more when i don't use all that I have. Quote
stryd_one Posted July 10, 2007 Report Posted July 10, 2007 There is much more to the code, parts in this function rely on mproc_event_table.I think i'll create a new table in flash memory for overall simpler handling and useability.And then can move the code to MPROC_NotifyReceivedEvntThat seems strange, but.... OK :)using a din had crossed my mind, but there are already 10 buttons on the pedal board. I only use 9. seems a little silly to add more when i don't use all that I have.Sounds to me like you have a perfect spare DIN ??? Quote
Durisian Posted July 10, 2007 Author Report Posted July 10, 2007 That seems strange, but.... OK hehe, i'm not a very good programmer ;DHave now built a new table containg name, status, data. Whole program is much simpler to work with now. Also altered the tap code slightly (principle the same, just written better)Sounds to me like you have a perfect spare DIN :) Behringer FCB1010 pedal board, it's not a midibox.The problem seems to be with clicks that are too fast.(code i was using was older than that posted, had used 120000 / bpmcountms, instead of 60000.) :-[Can now tap at 120bpm nicely and down to much slower. But can only get as fast as arounf 220-250 and the random-ness starts. hmmm... this calls for a sequencer..........hmmmmmmmmm, won't display over 255 - that can't be a coinsedence.edit:ALRIGHT! who's the joker that declared unsigned char bpm... I'll find 'em!!! :-[Thanks heaps for your help guys!! Quote
stryd_one Posted July 10, 2007 Report Posted July 10, 2007 hhehehemy pleasure to help, just so long as you document your cool tricks on the wiki when your'e done ;D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.