libctru icon indicating copy to clipboard operation
libctru copied to clipboard

First second mute with mic (great-refactor)

Open Rinnegatamante opened this issue 8 years ago • 3 comments

Seems first mute second is still here with microphone. This is the code i'm using that gives that problem: http://pastebin.com/58biXMur

Rinnegatamante avatar Dec 05 '15 15:12 Rinnegatamante

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.

Steveice10 avatar Dec 05 '15 18:12 Steveice10

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).

Rinnegatamante avatar Dec 05 '15 18:12 Rinnegatamante

Added this before StartSampling and nothing changed:

do { MICU_GetPower(&power); }while(!power);

Rinnegatamante avatar Dec 05 '15 19:12 Rinnegatamante

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.

Steveice10 avatar Dec 05 '15 20:12 Steveice10

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.

Rinnegatamante avatar Dec 06 '15 10:12 Rinnegatamante