Maker Pro
Maker Pro

Simple audio encoding... how?

P

Phil Allison

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.


** 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
 
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?

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

Frank Buss

Phil said:
** Don't bother -

the OP is a retarded & totally autistic fucking nut.

Phil, I enjoy your postings, if they are on-topic, because looks like you
know a lot about the topics discussed in this newsgroup, but please stop
the insulting postings, it doesn't help your reputation.
 
P

Phil Allison

"Frank Buss"
Phil, I enjoy your postings,


** Do not talk down to me - you posturing, stupid ass.

Nut case trolls like " Deblis " are NEVER TO BE TOLERATED.

Anywhere or anytime.

Shame you have no clue why that is.


Vote for the local Fascist Party do you ?




...... Phil
 
E

Eeyore

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

No help. That just means one channel.

Do you mean MONOTONIC ?

Do some research first please.

Graham
 
P

Phil Allison

<[email protected]>


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


** You got the WRONG universe

- you fucking AUTISTIC WANKER


Fuckwit software geeks = the planet's biggest public menace.

Worse than Nazis.



...... Phil
 
F

Frank Buss

Phil said:
Fuckwit software geeks = the planet's biggest public menace.

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

Frank Buss

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

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:

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

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.
 
P

Phil Allison

"Frank Buss"<
At least he tried it.


???????????????????

Piss off

- BLOODY SNIPPING IDIOT




........ Phil


Some hardware guys need software geeks like me, too,
 
P

Phil Allison

"Frank Buss"


** Missed the fucking buss is more like it.

Criminal, fucking looney, code scribbling puke.





......... Phil
 
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)
....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
 
M

MooseFET

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.

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
<--------------!+/ of Bob's suggestion
O CD4053
!
GND

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.

See the above to avoid the full cycle delay and get it every half
cycle.
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. <g>

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.
 
M

MooseFET

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 ?

BTW:

A one pole high pass that corners at about 20KHz

+ a comparator turning that into a square wave.

+ a low pass to return to a flat frequency responce

you can understand what is being said going into the input.
 
R

Roger Blake

** Do not talk down to me - you posturing, stupid ass.

You are nothing more than a liar and a coward. Go crawl back into
your hole, little one.
 
P

Phil Allison

"Roger Blake the Slimy Fake "


** Got a nice big brain tumor growing in that pointy head of yours ?

Hope it kills you - real soon

- pal.
 
R

Roger Blake

Hope it kills you - real soon

A weakling as well, I see. Liar, coward, weakling. Quite an array
of personal characteristics you have there. Pal.
 
...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

By the way, if you really want something which is not necessarily what
you specified in your original post, but rather you want a digital
signal which, when connected directly to a speaker, will sound like
the original audio, and which works for polyphonic music and speech as
well, then what you want is a 1-bit sigma-delta ADC. This results in
a bit stream that can sound quite good (e.g. Sony SACD or many
ordinary CD players also use a 1-bit DAC).

If you want a very simple circuit which approximates this well enough
for an intercom or phone quality of audio, then all you need is a D-
flip flop, an R-C filter and a comparator (which can be approximated
by a logic gate input if you want the cheapest system). If you have
never built one of these, you really should because it is very
surprising when you turn it on the first time with a walkman attached
to the input. Try some different resistor and capacitor values
because I have forgotten what works best. Make sure that you use the
inverting output of the flipflop for the feedback. I suggest 74HC74
devices. You could buffer the output with logic invertors to drive a
speaker. To keep the power dissipation low, put a big capacitor in
series with the speaker.

Basically, as follows (view in a fixed width font e.g. courier):

Audio in 10k 10k
*---||-/\/\/\-*----/\/\/\-,
100uF | _____ |
| | _| |
,---*--|D Q|--.
| | |
100nF--- | Q|-----Out
--- |_/_\_|
| 74HC74 |
--- Clk 1MHz
GND

By the way, you can emulate the D-flipflop using a fast
microcontroller if you want, by reading the state of one port bit (the
D input), and writing the value to another port bit (the Q output).

If you want a more fancy version, look here:
http://www.hypex.nl/technology.htm

Chris
 
B

boB

Phil, I enjoy your postings, if they are on-topic, because looks like you
know a lot about the topics discussed in this newsgroup, but please stop
the insulting postings, it doesn't help your reputation.

But it ~IS~ his/her reputation.
boB
 
M

MooseFET

---
Right.
What I had in mind was a digital peak detector using an ADC, a couple of
latches and a magnitude comparator.

I'm working on the schematic of the whole thing right now and I'll post
it to abse when I'm done, which will probably be late this afternoon or
early tomorrow.

How about this:

If you integrate (sum) the ADC output over a half cycle, the total
will give the length of time to hold the output high on the next half
cycle. This makes your amplitude the average rectified instead of the
peak but that seems just as good.
 
Top