Simple audio encoding... how?

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

Reply to
mdeblis
Loading thread data ...

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.

Reply to
MooseFET

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

Reply to
oopere

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

Reply to
mdeblis

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.

Reply to
BobG

Audio doesn't have a 'repetition fequency'. Do you mean the frequency of the audio ? There's a problem there, music isn't a single frequency. Squaring it sort of works I suppose except you'll see mostly LF content as a rule.

Averaged amplitude ? If so what time constant ?

What are you actually trying to do ?

Graham

Reply to
Eeyore

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

Reply to
Doug B.

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"
Reply to
Jamie

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.

Reply to
miso

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

Reply to
mdeblis

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?

Reply to
Jasen Betts

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,,,

Reply to
mdeblis

No help. That just means one channel.

Do you mean MONOTONIC ?

Do some research first please.

Graham

Reply to
Eeyore

e

Yes. Though I was using musical terminology

formatting link
wiki/Polyphonic) where monophony is a single voice, vs. polyphony is multiple. Monotonic, as in a single frequency, if what I'm hoping for.

I'm doing that - not my area, this, simple software guy - got the wrong word...

Thanks

Reply to
mdeblis

At least he tried it. Some hardware guys need software geeks like me, too, even for writing a "hello world!" application :-)

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

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
Reply to
Frank Buss

To get a voltage proportional to amplitude without filtering (which would have time-constant-vs-ripple issues), you could feed the input into both a zero-crossing detector (comparator) and into an op-amp integrator. When the comparator output goes low, it fires a one-shot that samples the integrator. This is just a CMOS switch (CD4016 section) that is closed briefly to charge a cap, whose voltage is monitored by an op-amp buffer. When the one-shot is done, the integrator cap is shorted by another

4016 section for the rest of the half-cycle.

The result if all this is that the buffer output will have a voltage proportional to the integrated amplitude of half the incoming wave. It will hold at that value until completion of the same half-cycle of the following wave cycle, and then it will step crisply to the new voltage.

If you had a fixed-frequency input, then you could just use this voltage to set the duration of a one-shot. But it sounds like what you really want is to control the duty cycle of the output for varying input frequencies (PWM). This would probably be best done with some sort of dual-slope approach, the details of which I haven't worked out yet.

Best regards,

Bob Masta DAQARTA v4.51 Data AcQuisition And Real-Time Analysis

formatting link
Scope, Spectrum, Spectrogram, Sound Level Meter FREE Signal Generator Science with your sound card!

Reply to
Bob Masta

--
if you want to use a _single_ frequency, neither 'monotonic' nor
'monophonic' is correct since, for the former, the signal voltage
changes polarity periodically and, for the latter, octave-related
frequencies can appear simultaneously on the single signal.

http://en.wikipedia.org/wiki/Monotonic_function

http://en.wikipedia.org/wiki/Monophony

I take it that what you'd like is a system where, say, a piano was being
played, one note at a time, and for each note played you'd like to have
an output pulse train with a period which corresponded to the frequency
of that note and a period which corresponded to its amplitude.

Something like this?: (View in Courier)


         ||
          _                                    _
A440pp __| |__________________________________| |____________

       ->| |
Reply to
John Fields

On Dec 5, 2:18=A0pm, John Fields wrote: ...

...snip

Absolutely. Thank you. I was going to stick on an input low-pass filter with a 3dB point at about 5kHz to simplify things a bit. But, yes, single notes.

Cheers

Reply to
mdeblis

That is a good idea but it is a type of filter.

Note the comparator I suggested and view in fixed font:

---+-----/\/\---+-----/\/\--- ! ! ! ! --!-\ ! O ! >------+--- to integrator out yet.

How about:

Make your integration a real integration that resets on the edges.

OR (1) Voltage controlled one-shot

(2) Integrate output of (1)

(3) Use op-amp to servo to duty cycle.

Reply to
MooseFET

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.