Simple audio encoding... how?

Dec 04, 2008 29 Replies

Hi,



I want to encode a mono audio signal into a digital squarewave where the repitition frequency is the same as the instantaneous incoming audio, and the pulse width is proportional to the amplitude.



It's easy enough to clip the audio to get the right repitition frequency, but I'm not sure about the amplitude encoding. Something simple with 555s or similar would be great...



Ideas welcome.



Thanks



Mike


On a sunny day (Thu, 4 Dec 2008 06:10:23 -0800 (PST)) it happened snipped-for-privacy@hotmail.com wrote in :

As Phil mentioned, that will not work. Because if you have a very low freuency, say 100 Hz zero crossing, the waveform will have smaller higher frequency amplitude components. Those need a higher sampling rate, so to speak, so you lose those high frequencies because your PWM repeat will be 100 Hz in that case.

Consider this waveform (fixed font):

. ------ . . . high frequency component . . . ------ zero . . zero

------------- pwm ___| |________

Was that your idea?

This almost works:

I assume that this is a one frequency at a time sort of thing. You already know how to make a square wave with a comparator.

(1) Sync rectify the input

(2) Filter the rectified to make smoothish voltage.

(3) Use a few more comparators to make a voltage dependent oneshot.

The pulse width and not the duty cycle is controlled by the signal amplitude.

requency component

You are assuming something about the OP's needs that I don't. I assumed that the signal was just one frequency at a time.

On a sunny day (Thu, 4 Dec 2008 06:51:39 -0800 (PST)) it happened MooseFET wrote in :

He stated 'audio', both in the subject line and in the article body. So who is assuming ;-)?

This could be FM, if you mean that the repetition frequency is proportional to the instantaneous value of the audio signal...

This could be PWM...

So, you want _simultaneous_ FM and PWM? Why?

It seems your question needs some further clarification.

Pere

Good question. The resultant FM & PWM pulse train will be used to gate a high frequency pulse train, probably in the order of 400kHz. I want a recognisable form of the original audio, very much NOT hi-fi but recognisable none-the-less, to be recoverable from the final, gated, high-frequency pulse train.

My bad - I should have been more explicit - part of the issue is that I wasn't too sure of the final requirement myself.

many thanks for all your comments so far - very helpful.

Assuming now that I'm after FM & PWM, and I'm not worried too much about nyquist or hi-fidelity, can anyone recommend a simple approach using say a PWM controller like the TL494 or whatever?

Cheers

You can sort of understand the output of audio fed into a zero referenced comparator... sort of a 1 bit digitizer that roughly follows the zero crossings, so it has a lot of fundamental in it.

If you can live with a course-grained view of your audio how about feeding it into a network of comparators similar to the level meter here?

formatting link
er.gif.

Hook each output to a resistor in a voltage divider network and use the resulting voltage to control the PWM function of a 555. See here

formatting link
for an idea.

doug

Boy! You've sure accumulated a bunch of crap anwsers! Ignore them. Send the audio to a zero-crossing detector, and log the time interval between zero crossings.

Send the resulting data stream to any ol' buffer, and it will sound surprisingly accurate, but with a lot of high frequency artifacts, which should be fairly easy to filter out.

Back before the days of sound cards, I heard a herald trumpet fanfare on my computer's own speaker on some vendor's ad CD.

Good Luck! Rich

SWP/VSM Space width modulation/Variable Space Modulation.

A known trick used in simply things like RC control toys.. some types of remotes etc.

Pulse rate is detected at the receiver to select a channel of control while the duty cycle (width) is used for proportional control of that channel.

for basic application of, use a PIC/AVR or what ever to sample a complete transition onto the start of the next. Sample the time window as the frequency and the duty cycle as the proportional scale.

Have a good day! :)

http://webpages.charter.net/jamie_5"

e

nd

y,

5s
d

I think Eeyore had the right answer. You only get one frequency with this scheme.

Probably the PC trumpet sound you heard was done via PWM. The early voice synthesis chips used this technique.

d

Thanks for the help. It's appreciated - I'll try this approach and see what happens. Not being an EE, it's sometimes tricky knowing where to start. I'm happier with s/w than h/w...

I've got an AVR in the circuit - I'l also try digitising the stream with a free-running ADC (8 bits would be fine), using the zero crossing to determine the pulse interval, and take the peak amplitude in the interval to determine the pulse length. Though this is crude, it should give me roughly what I need. I could always perform a faily short FFT (say 1024 bit) on the input stream, extract the fundamental/ peak energy frequency and its power, and use that, though in this instance it may be overkill...

Many thanks

suppose your audio cosists of a 1Khz sine wave as 0.5V superimposed with a 3.141 khz sine wave at 0.321v

what should the "square wave" look like?

** Wot insane, pseudo technical, verbal diarrhoea.

At very best.

Demented ravings of a congenitally autistic, narcissistic freakoid is what it really is.

DO NOT ANSWER THIS TROLL !!

.... Phil

** Wot insane, pseudo technical, verbal diarrhoea.

At very best.

Demented ravings of a congenitally autistic, narcissistic freakoid is what it really is.

DO NOT ANSWER THIS TROLL !!

.... Phil

** Wot insane, pseudo technical, verbal diarrhoea.

At very best.

Demented ravings of a congenitally autistic, narcissistic freakoid is what it really is.

DO NOT ANSWER THIS TROLL !!

.... Phil

Thanks for the help. It's appreciated

** Wot insane, pseudo technical, verbal diarrhoea.

At very best.

Demented ravings of a congenitally autistic, narcissistic freakoid is what it really is.

DO NOT ANSWER THIS TROLL !!

.... Phil

You have a good point - I didn't express myself well, and didn't explain the issue properly. I'm hoping that the source with be monophonic, and the various approaches suggested so far have helped me clarify what I need to do. If the source ends up being polyphonic, or the simplistic approaches end up being unsuitable, then I'll move to the FFT one I mentioned elsewhere - I've used that before so already have workable code in GCC...

Thanks for your comment,,,

I think an ADC might be a good idea, some microcontrollers have them integrated, too, so you don't need much external components at all. But a FFT needs quite some processor power, so might be difficult with an AVR. If you need just detect some known frequencies, you can try this algorithm:

formatting link

You can adjust a bit the bandwidth by selecting the right window function. I've used this with a DSP for analyzing sine signals for multiple channels in parallel at 48 kHz and works nice.

Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required