Require assistance porting WaveHC to Zero. Specifically timers + SD lib


i've posted github repository work far here:
https://github.com/rabidprototypes/wavehczero

i saw alloysetech has some work timers here:
https://github.com/aloysetech/zerodio/blob/master/zerodio.cpp


after looking through timers used agree decision use tc5 audio, used tone, , don't need tone @ same time wav file.  and tc4 used servos, need @ same time wav playback. tc3 available, best leave else.  and don't know tcc0, 1, , 2 might used standad arduino libs or if can used sort of thing.  as tc6 , 7, don't exist except on samd21j.

i decided easier @ same time port library on new sd library instead of trying use older sdfat stuff.  they appear similar , based on older sdfat lib, think maybe work few class name changes , few other tweaks.  i don't know if there performance hit though.  but removed files sd , fat access, dac files, we'll using on board dac this.

finally, version of library contains bunch of tweaks made. has fine volume adjustment can control volume pot digitally, , limits slew rate of volume avoid pops.  this works prevent pops when powering board, slews speaker center instead of jumping there. in addition has ability automatically loop wav, , supports peak detection use sound reactive lighting.


so anyway... first order of business don't understand how tc's on 0 work precisely.  i think can configured atmega... wavehc lib needs 2 counters on 1 timer, each triggering different isr @ different times, , don't know how accomplish that.  so far i've been able find simple examples set single function, , maybe can set 1 function , have work things differently.  i'm not sure.  

code this:
code: [select]

void tc5_handler (void) __attribute__ ((weak, alias("audio_handler")));


i don't understand.  it seems setting 1 handler... don't see how set more 1 each counter.  nor know "weak" does.  and seems strange me specify name of function want call in quotes that.  i don't understand @ all.  i have expected like, function pointer or something.

on other hand in servo lib have this:
code: [select]

void servo_handler(timer16_sequence_t timer, tc *ptc, uint8_t channel, uint8_t intflag);
#if defined (_usetimer1)
void handler_for_timer1(void) {
    servo_handler(_timer1, tc_for_timer1, channel_for_timer1, intflag_bit_for_timer_1);
}
#endif
#if defined (_usetimer2)
void handler_for_timer2(void) {
    servo_handler(_timer2, tc_for_timer2, channel_for_timer2, intflag_bit_for_timer_2);
}
#endif

void servo_handler(timer16_sequence_t timer, tc *tc, uint8_t channel, uint8_t intflag)


and seems set 2 different handlers 2 counters... or channels, guess they're called?  on tc4... except don't know name handler_for_timer1 comes or how specify called when channel? reaches specified value.

and of course there's other code in library still have fix up.  it doesn't write dac yet, still set mcp external dac, , old sd library, , multiplication code in assembly needs ripped out since atmega.  but i'm trying figure out how replace 2 isr() function calls , set timers.

code: [select]
void tc5_handler (void) __attribute__ ((weak, alias("audio_handler")));

the tc5_handler() interrupt handler, anytimes there interrupt triggered on tc5 (overflow, match, etc...), function called. have check in function cause of interrupt. weak attribute bit special , looks strange @ first. in few words, lets declare function replace later. here it's audio_handler(), called @ each tc5 interrupt.

doesn't zerodio lib fits needs in term of audio? i've been working on lot few months ago didn't push on github : play 4 wav file simultaneously, volume adjustment, pop reduction etc. needs lot of work clean , solve glitches.


Arduino Forum > Products > Arduino Zero (Moderator: cmaglie) > Require assistance porting WaveHC to Zero. Specifically timers + SD lib


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'