Shop OBEX P1 Docs P2 Docs Learn Events
OBJ File Causes Noise. — Parallax Forums

OBJ File Causes Noise.

Chad1Chad1 Posts: 26
edited 2014-11-23 16:58 in General Discussion
Hi all,

I'm working on a project that uses a Propeller, a microSD card, a cheap 0.25W speaker (with LM386 audio amplifier), and the WAV-Player_DACEngine.spin object file (attached). Everything works fine, but there's an annoying issue I'd like to work around. For simplicity, let's say my program waits for the user to press a button which triggers an audio clip to play. Otherwise nothing happens.

My Issue:
When my program runs, even before the button is pushed to trigger audio, the speaker emits some noise. The noise disappears when I comment out the WAV-Player_DACEngine.spin file in the OBJ declaration section. Obviously this means all audio capabilities are killed, but the point is the noise is related to the inclusion of the WAV-Player_DACEngine.spin file in the program.

My Goal:
Avoid the object file being used continuously from power-up to power-down. It needs to be leveraged only when audio is required, not while waiting for a button press. This will also help optimize the power consumption of my project.

My Question:
When waiting for a button press, I'd like the speaker system off/unused. Can someone help me implement this solution, or suggest ideas on how to implement one (in Spin)? I'm a relative novice, so my first ideas may be unrealistic or inefficient. My first thought is to not declare the WAV-Player_DACEngine.spin object file in the main program, rather in a separate file which is accessed by the main program on my command.

Thanks!

Comments

  • JDatJDat Posts: 103
    edited 2014-11-23 06:07
    Figure out what is noise source.
    1) It's recommended to build better audio filter.
    2) Try to stop DAC engine. PWM output allways make noise.
    3) Try to stop FAT engine. Interference from SD card goes to audio lines.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-11-23 09:25
    There are some inherent noise issues with audio on the Propeller 1, having to do with its architecture. I learned this the hard way during the development of the EFX-TEK AP-16+ (which I co-designed and coded). I was so frustrated by noise that was not in the audio that I turned to Chip Gracey for help. He solved the problem by adding high-frequency white noise to the audio which gets filtered out in the RC DAC. This takes an extra cog to do properly. Some have claimed they can add "noise shaping" without the other cog, but -- in my experience -- this doesn't hold up when you amplify the audio to any degree (the AP-16+ has 20W amps).

    I use my own WAV driver (object and demo that runs on PAB is attached). There is a parameter for Chip's STEREO_DACS cog that lets you control how much extra noise to add. I have found this needs to be tuned per application. This will all go away with the next generation Propeller which has DACs built in.

    The LM386 is not a great amp and can do all kinds of wild things if not handled delicately. For example, the one on my old PDB will pick up a local radio station at times -- it's wacky. For a commercial product that EFX-TEK is developing for a client we are using the TDA7052A which has better power and a volume control input that we use as a mute pin. The circuit set-up defaults to un-muted (if you don't have a spare pin for mute); to mute the amp, take the MUTE line high. We're very happy with the result; when the mute pin is high the speaker is dead quiet.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-11-23 09:29
    Chad1 wrote: »
    The noise disappears when I comment out the WAV-Player_DACEngine.spin file in the OBJ declaration section.

    Is there noise when the object is left but not started? Just having the object listed in the OBJ section shouldn't be causing noise. I'd think you'd have to start the object for it to affect the sound output.
  • Chad1Chad1 Posts: 26
    edited 2014-11-23 16:24
    Duane Degn wrote: »
    Is there noise when the object is left but not started? Just having the object listed in the OBJ section shouldn't be causing noise. I'd think you'd have to start the object for it to affect the sound output.

    Yes, the noise occurs when the file is included and never used. I agree it seems like that shouldn't happen, so that's why I'm a bit stumped on how to proceed.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-11-23 16:36
    Chad1 wrote: »
    Yes, the noise occurs when the file is included and never used. I agree it seems like that shouldn't happen, so that's why I'm a bit stumped on how to proceed.

    If you post your code, someone might be able to figure out the issue.
  • Chad1Chad1 Posts: 26
    edited 2014-11-23 16:58
    Actually, I don't think the object file is causing the issue.To power the LM386 I'm using a 5V regulator which has an enable pin. I'm driving said pin with Propeller IO. Not sure how it happened, but the code I was using to test the noise issue didn't have the Propeller pin for the 5V enable defined as an output. So, when the noise would disappear it was because I wasn't really powering the LM386. JonnyMac is right, it seems my LM386 is causing the issue.

    The noise is rather quiet in volume and is just one continuous high pitch with some soft fuzz behind it. It's not a big deal, but it's annoying to know I'm burning power unnecessarily. Sorry for the false alarm. I appreciate the thoughts and advice!
Sign In or Register to comment.