2016-09-26 12:00 PM
Hi.
I seem to be unable to post replies to threads in this forum. A proxy-error page appears and I'm not using a proxy server. Sometimes a ''CAS/login'' error appears. I'd like to use the STM32F746G Discovery as a DSP effect unit and wonder if it is possible to get around the limitation that the BSP_AUDIO_IN_OUT_Init function only is compatible with the on board microphone due to shared timeframes. It should be possible to use the same DMA audio buffer to both read the line-in input and to transmit it to the headphone jack. In order to do this I guess it would be necessary to use the same IRQ timing for both input and output. This is the smart way of doing DSP. I can only output data and at the moment I use the DMA transfer callback routine to prepare the new output buffer. In fact it is required to use the DMA half transfer complete for the other half in order not to mess up the buffer data. It took me long time to figure this out. It would've been so much easier if the examples provided would've had minimalistic examples together with the more advanced applications. An example that just passes audio from line-in to headphone jack with maybe a simple amplitude change would've been very pedagogical in this context. Another simple waveform output example would've been very nice too. If I get this to work I might provide these myself.2016-09-26 12:20 PM
Use ''Sign in to forum'' on the right pane and then Reply, it has been broken for months.
You could use the same buffer, you'd like want to split it in two, having DMA work on opposing halves. You'd perhaps want to use the double-buffering scheme, or the HT/TC signals.2016-09-26 02:44 PM
I'm already using two halves of the buffer when outputting the audio. Otherwise the audio will be affected by the updating process in the callback routine. This is how i did it for outputting a sine wave on the left channel and a triangle on the right channel.
#define BUFLEN 128
#define FREQ 11650000
uint32_t samplecounter = 0;
// the function ''readinterpolated'' outputs the waveform amplitude. The input phase is given as a uint32_t.
void
BSP_AUDIO_OUT_HalfTransfer_CallBack()
{
// update first half of buffer
for
(
int
i=0; i<BUFLEN/2; i++)
{
// left channel
buffer[i*2] = readinterpolated(samplecounter*FREQ, sindata)*32000.0f;
// right channel
buffer[i*2+1] = readinterpolated(samplecounter*FREQ, triangledata)*32000.0f;
samplecounter++;
}
}
void
BSP_AUDIO_OUT_TransferComplete_CallBack()
{
// update second part of buffer
for
(
int
i=BUFLEN/2; i<BUFLEN; i++)
{
// left channel
buffer[i*2] = readinterpolated(samplecounter*FREQ, sindata)*32000.0f;
// right channel
buffer[i*2+1] = readinterpolated(samplecounter*FREQ, triangledata)*32000.0f;
samplecounter++;
}
}
However when initializing the BSP_AUDIO_IN_Init and BSP_AUDIO_OUT_Init separately it seems like the data written to the buffer from the input jack is out of sync with the updating of the output buffer. One could of course have the input to a separate circular buffer and fetch that data from the output buffer but I see no reason why such a workaround should be needed.
Edit: I forgot to mention that I want to be able to superimpose the incoming audio from line-in to some generated waveform such as the example above.
2016-09-27 04:12 PM
Btw is it possible to input stereo audio from the blue line-in jack? In the audio library it seems like I must choose between INPUT_DEVICE_INPUT_LINE_1 or
INPUT_DEVICE_INPUT_LINE_2 but I have no idea how to combine them. It did not work to just combine them by a ''binary-or'' operation.