libctru
libctru copied to clipboard
First second mute with mic (great-refactor)
Seems first mute second is still here with microphone. This is the code i'm using that gives that problem: http://pastebin.com/58biXMur
Try waiting a bit after micInit before starting sampling. The issue generally seems to be sampling too soon after telling it to power on the microphone.
In fact, can you check the power status right after micInit? If it's still false, I might be able to add a wait for it in micInit.
EDIT: Also, you shouldn't be freeing the microphone buffer and then using it as your audio buffer. Once you free something in C, it should not be used again.
Yeah i know i shouldn't free it, infact the free you see was related to an old version of the same piece of code (i forgot to comment it).
Added this before StartSampling and nothing changed:
do { MICU_GetPower(&power); }while(!power);
Can you try a normal sleep for a bit then? I know for sure that it works fine with the MIC example, which doesn't immediately start sampling after micInit.
Using svcSleepThread(1000000000); seems to work but now i (obviously) have a sleep for a second. What could be an optimal value?
EDIT: Not related to the issue: Is it possible to change how mic works to use memory allocated with linearMemAlign? Using memalign seems to produce a buffer which can't be directly reproduced with csnd:SND so i have to waste clock cycles to do a memcpy to a buffer allocated with linearAlloc after recording.