I am new to audio processing. I wrote a simple real-time playback program (when you speak on the mic your voice is immediately played on the output), however it is not working. I am using a 8Hz ADC with 128 frame size, and I output these 128 samples directly to audio PWM. It doesn't play the audio even though there's a "reaction" when you tap the mic.

Is there a processing needed before outputing the samples, that would explain why it isn't working ?

Here is my main loop :

while (1) {

while (ADCChannelIsBusy(MyADCHandle)){}
ADCChannelRead  (MyADCHandle, Frame, ADC_BUFFER_SIZE);


I wrote none of these functions, all were found in the dsPic starter Kit. Frame is the array where samples are stored.


closed as off-topic by Jason R, lennon310, jojek, Matt L., Peter K. Apr 14 '14 at 19:47

  • This question does not appear to be about signal processing within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ What do you mean by "directly to audio PWM"? What exactly is the software interface to hardware? $\endgroup$ – hotpaw2 Apr 10 '14 at 0:46
  • $\begingroup$ I mean the built-in PWM decoder peripheral. I am using a dsPic starter kit(dsPic 33F) with Microchip's IDE. $\endgroup$ – user7439 Apr 10 '14 at 0:48
  • 4
    $\begingroup$ This question appears to be off-topic because it is about hardware requirements to generate audio. It would be better suited on electronics.SE. $\endgroup$ – Jason R Apr 10 '14 at 13:32

This is unlikely to be a signal processing question. This is about the internals of the dsPic's firmware libraries and would be more suitable on another stackexchange site.

Things that could go wrong:

  • ADC input and PWM output might have a different data format (for example 12-bit right justified for the ADC, 8-bit for the PWM). You might need to scale / offset the data.
  • ADC_BUFFER_SIZE and OCPWM_FRAME_SIZE might be of different sizes, requiring you to use an intermediate buffer and counters to keep track of data pouring in/out of this buffer. Or, if the implementation allows it, you might instead read/write partial buffers of a smaller size - identical for both calls.

Not the answer you're looking for? Browse other questions tagged or ask your own question.