No announcement yet.

How to generate audio

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to generate audio

    Hello I want to use the intrernal PWM audio. How it is linked with system? How can I generate audio output.

    thank you.

  • #2
    What kind of audio are you wanting to generate? For playing music from files there are things like "aplay" and "madplay" for wav files and mp3 files respectively (from the command line) or normal Linux GUI applications (a bit power hungry and can cause problems - command line is recommended). For other access the system is a Linux computer using "alsa" so you can interface to the audio system in the same way as for any other Linux system. That includes using things like PulseAudio, Jack, etc. You can also use the Alsa "OSS" compatibility layer "alsa-oss" to provide the wrapper command "aoss" to give any program you write pseudo-access to the OSS /dev/dsp virtual file for streaming PCM data to the audio device.


    • #3
      Hello, thanks for answer. I know all about Alsa and OSS, I'am using it in other projects. But when Armadillo boots up, I cant's see any /dev/audio or /dev/dsp. Therefore I asked how to generate audio. Do I need to enable something to see the Audio devices?


      • #4
        Alsa has no /dev/ entries. I'm not entirely sure how you interface with it TBH. If you use the aoss wrapper then your program can open /dev/dsp even though it doesn't actually exist - it forwards the data on to Alsa.


        • #5
          I am using a uLCD43 and I have used the wav sound calls successfully to generate tones for a glider variometer. However I am not happy about the reliability of using the SD files continuously. I can use the snd_Freq to generate tones, but I have lost the volume control! Could I wire one of the PWM channels to AUDENB to modulate the amplifier bias? Also is it possible to directly program the AUDIO PWM generator rather than using the file system and it's driver? Any help very welcome...


          • #6
            Hi bnsearle,

            If you're trying to use the AUDIO out pin and the PWM pins, maybe you could try using an external transducer (speaker), control circuit (like a potentiometer) for the volume and add an external circuit to improve the quality of the sound the LCD is only generating square waves with 0 - 3.3v..

            Also, Is it ok to ask what problems or concerns are you encountering with using the uSD cards?



            • #7
              Hi Joseph
              I have read the posts about problematic SD cards and so I am using Zectron Xtreme Photo pro 2 GB cards. These presumably will not hang up in a camera so should be OK.

              I think that the wav file method is fine for voice messages etc, but I am reluctant to use this method to continually read the same file every second to generate a simple sine tone. So to get a volume control I have a spare PWM pin that I could wire to the AUDENB pin, then I can use:

              pin_Set(PIN_INP_HI, AUDIO_ENABLE) ; // this compiles with no errors, so OK to drive AUDENB! . .
              pwm_Init(PA13, PWM_PLAIN, duty_cycle) ; // volume control ratio chopping at 70kHz

              Will this work?

              Is there a way I can directly program the AUDIO output with PWM so that I can generate a sine wave? That would be the nicest way, but as you say I could add a separate audio amp, but that's a pity when there is one on the PCB!

              Thanks Bryan


              • #8
                No the only way you can generate a sine wave is by using a uSD with a .wav file on it.

                A card specifically designed for a camera, in general, is simply designed for 'high write speed', it has no 'read disturb' protection.

                'Read disturb' appears when you read the card many times without writing. it results in random bit changes to the data on the card. Once upon a time it took many reads to 'expose' this issue, as the density of cards increased the time to expose the issue becomes shorter and shorter in a non linear manner.

                Many newer cards will display the issue in as few as 20,000 reads without rewriting the data.

                We are talking about 'all' flash memory, not just uSD cards.

                Industrial cards with 'read disturb' protection have been created to protect against this issue.

                Because of the increasing prevalence of this issue we now only sell cards with this protection on out web site.

                We have tested these cards with over a billion reads without a rewrite and they still are not displaying any issues.

                You might like to have a read of this


                • #9

                  Thanks for the data on the flash read disturb problem. That makes me even more nervous about continually reading the SD card to generate a beep tone! Do you have a list of 4D approved SD cards?
                  I have been working on a solution that uses the 'pin_PulseoutCount' function. I set the pin to output open-drain, then generate a voltage using another pin and 'pin_Pulseout' (called in a 100ms timer function that is used for various other purposes) as a low speed PWM to an RC average circuit. This voltage is used to modulate the amplitude of the 'pin_PulseoutCount' function pin and using some resistor gives me a volume control! This signal is fed to the speaker amp circuit at the junction of R42 and C37. I am just optimising the components to give a good dynamic range and a quasi sine wave.



                  • #10
                    No we don't have a list of approved cards.

                    We simply specify that they must have 'read disturb' protection. If you choose to use a make/model other than the one we sell you will have to perform your own testing.

                    Since manufacturers change the cards 'internals' regularly (not just hardware changes, but also software changes to fix bugs) we cannot possibly test them all.

                    The cards we sell are tested every time there is a hardware and/or software change as the manufacturer notifies us of forthcoming changes and makes early samples available for us to test.