On May 15, 12:20=A0am, Rohit <papakap...@gmail.com> wrote:
>
> I do not understand this. could you please explain the process to do
> this. I do not want to use a DAC.
> Can i implement what you are suggesting with just pwm? Currently I am
> generating square waves of 50% duty cycle
> with different frequencies to produce different notes of keyboard.Do
> you mean i must also vary duty cycle of the pulses.
You seem confused on what PWM is - you claimed to be using it, then
state here that you always use 50% ?.
If you want to vary the amplitude, you need other than 50% - Varying
the duty cycle is a cheap way to vary the energy, but it does also
affect the spectrum - if you want to preserve harmonic shape, then you
need an external means of Amplitude control.
In a simple uC, you could use one PWM as a slower DAC for envelope
shape, and a 2nd PWM driving an external SPCO Analog switch, to give
frequency control.
Or, you can just move up in frequency, and use single PWM as a faster
DAC, and use the uC to 'play back'
a recorded waveshape. That will give the best sound-effect quality by
far, and large flash memory really is cheap.
-jg
Reply by Jon Kirwan●May 14, 20092009-05-14
On Thu, 14 May 2009 08:32:06 -0500, Vladimir Vassilevsky
<antispam_bogus@hotmail.com> wrote:
>Rohit wrote:
>
>> On May 14, 4:37 am, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
>> wrote:
>
>>>For gunshots, blasts and such, generate the stream of random numbers and
>>>apply rapid attack - slow decay envelope to it.
>>
>> I do not understand this. could you please explain the process to do
>> this. I do not want to use a DAC.
>
>You got the general directions. However I am solving other people design
>problems as the business. If you want me to work on the project, the
>contact is at the web site.
I'm frustrated that the OP didn't take your comments further before
asking that question, but this comment from you also makes me think
this is the primary reason you post. It wouldn't have been hard to go
another inch or two for the OP.
To each their own.
Jon
Reply by Jon Kirwan●May 14, 20092009-05-14
Reply by Vladimir Vassilevsky●May 14, 20092009-05-14
Rohit wrote:
> On May 14, 4:37 am, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
> wrote:
>
>>For gunshots, blasts and such, generate the stream of random numbers and
>>apply rapid attack - slow decay envelope to it.
>
>
> I do not understand this. could you please explain the process to do
> this. I do not want to use a DAC.
You got the general directions. However I am solving other people design
problems as the business. If you want me to work on the project, the
contact is at the web site.
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
Reply by Rohit●May 14, 20092009-05-14
On May 14, 4:37=A0am, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
> Rich Webb wrote:
> > On Wed, 13 May 2009 17:32:51 +0200, Legato <leg...@albasani.net> wrote:
> >>Rohit wrote:
>
> >>>I am working on a hobby project to generate sound effects with 89c2051
> >>>using PWM. I am able to generate keyboard notes with it by generating
> >>>pwm signals of different frequencies. But I am at loss as how to
> >>>generate
> >>>other effects like car crashing,bird chirping,machine gun sound etc. ?
>
> For gunshots, blasts and such, generate the stream of random numbers and
> apply rapid attack - slow decay envelope to it.
I do not understand this. could you please explain the process to do
this. I do not want to use a DAC.
Can i implement what you are suggesting with just pwm? Currently I am
generating square waves of 50% duty cycle
with different frequencies to produce different notes of keyboard.Do
you mean i must also vary duty cycle of the pulses.
> Clicking sounds are emulated by the burst of the square wave with just
> two quickly alternating frequencies. The "color" of the click depends on
> the frequencies and the alternation rate.
One other problem which I am facing is that I am unable to find for
different sounds as mentioned earlier what
is the base frequencies for the sound effects. For example how to find
out for crashing sound what is the base frequency which has to be
applied in decaying fashion.
> Vladimir Vassilevsky
> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com
-Rohit
Reply by Frank Buss●May 13, 20092009-05-13
Rohit wrote:
> I am working on a hobby project to generate sound effects with 89c2051
> using PWM. I am able to generate keyboard notes with it by generating
> pwm signals of different frequencies. But I am at loss as how to
> generate
> other effects like car crashing,bird chirping,machine gun sound etc. ?
>
> I googled but could not find exact idea.
Some ideas for search terms: Digital sound synthesis, fm sound synthesis,
adsr envelope. A nice program for experiment with different ideas before
implementing it in a microcontroller is Csound ( http://www.csounds.com )
But creating a realistic car crashing sound would be difficult in software,
maybe a simpler solution would be to attach a SD card to your
microcontroller and just play some samples.
But if you like to do some really challenging, you could try to implement a
realistic sound synthesis in software with your MCU. At least on PC it is
possible to create a nearly raytraced looking realtime 3D animation of some
snowy mountains with cool music in just a 4k program and no other files
(yes, that's really just 4096 bytes :-)
http://www.youtube.com/watch?v=_YWMGuh15nE
Of course, the 3D functions of the OS are used for displaying the landscape
(which was nevertheless calculated by the program), but I assume the sound
was created by sound synthesis by the program.
--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de,http://www.it4-systems.de
Reply by Vladimir Vassilevsky●May 13, 20092009-05-13
Rich Webb wrote:
> On Wed, 13 May 2009 17:32:51 +0200, Legato <legato@albasani.net> wrote:
>>Rohit wrote:
>>
>>>I am working on a hobby project to generate sound effects with 89c2051
>>>using PWM. I am able to generate keyboard notes with it by generating
>>>pwm signals of different frequencies. But I am at loss as how to
>>>generate
>>>other effects like car crashing,bird chirping,machine gun sound etc. ?
>>>
>>To do that you would need to record those sounds and play back the samples
>>(under Windows these would be stored in a .wav file) using 1-bit PWM.
> Not really required.
Exactly. It takes too much of memory.
> For a chirping bird, for example, try a couple of
> short bursts of a high-pitched tone followed by a slightly longer burst
> of a lower tone, the whole sequence repeating four or five times.
> A
> machine-gun-ish sound could be two bursts in rapid succession, low and
> lower, and repeat.
For gunshots, blasts and such, generate the stream of random numbers and
apply rapid attack - slow decay envelope to it.
Clicking sounds are emulated by the burst of the square wave with just
two quickly alternating frequencies. The "color" of the click depends on
the frequencies and the alternation rate.
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
Reply by -jg●May 13, 20092009-05-13
On May 14, 3:15=A0am, Rohit <papakap...@gmail.com> wrote:
> hi,
>
> I am working on a hobby project to generate sound effects with 89c2051
> using PWM.
If you flip to the AT89LP2052/4052, you get smarter timers, and scaled
PWM
is easier. (and the core is much faster)
Same code, same socket.
> I am able to generate keyboard notes with it by generating
> pwm signals of different frequencies. But I am at loss as how to
> generate
> other effects like car crashing,bird chirping,machine gun sound etc. ?
>
> I googled but could not find exact idea.
Such sounds will always be a compromise.
The LP4052 also has a SPI interface, so you could stream from a SPI
Flash, to create
your Audio.
If you are getting into complex effects, then you are probably best
working on the PC
first, to analyse the sounds, and morph them into what you can play
back on the uC
Flash is cheap enough, that more storage can save a lot of effort :)
-jg
Reply by Jon Kirwan●May 13, 20092009-05-13
On Wed, 13 May 2009 12:12:25 -0400, Rich Webb
<bbew.ar@mapson.nozirev.ten> wrote:
>On Wed, 13 May 2009 17:32:51 +0200, Legato <legato@albasani.net> wrote:
>
>>Rohit wrote:
>>
>>> hi,
>>>
>>> I am working on a hobby project to generate sound effects with 89c2051
>>> using PWM. I am able to generate keyboard notes with it by generating
>>> pwm signals of different frequencies. But I am at loss as how to
>>> generate
>>> other effects like car crashing,bird chirping,machine gun sound etc. ?
>>>
>>> I googled but could not find exact idea.
>>>
>>> -Rohit
>>
>>To do that you would need to record those sounds and play back the samples
>>(under Windows these would be stored in a .wav file) using 1-bit PWM.
>>Haven't done it myself, but I've seen C source code which plays sounds
>>through the PC speaker, which uses similar technology. Google for that.
>
>Not really required. For a chirping bird, for example, try a couple of
>short bursts of a high-pitched tone followed by a slightly longer burst
>of a lower tone, the whole sequence repeating four or five times. A
>machine-gun-ish sound could be two bursts in rapid succession, low and
>lower, and repeat.
I'd also recommend at least considering linear predictive coding on
occasion, using one or more individual sets of coefficients and maybe
even sometimes not bothering to keep every bit of data (residuals,
starting values); plus huffman coding can be applied at times, as
well.
But the basic idea is that there are many different useful methods and
people have probably found uses for _more_ than all of them. ;)
Jon
Reply by Rich Webb●May 13, 20092009-05-13
On Wed, 13 May 2009 17:32:51 +0200, Legato <legato@albasani.net> wrote:
>Rohit wrote:
>
>> hi,
>>
>> I am working on a hobby project to generate sound effects with 89c2051
>> using PWM. I am able to generate keyboard notes with it by generating
>> pwm signals of different frequencies. But I am at loss as how to
>> generate
>> other effects like car crashing,bird chirping,machine gun sound etc. ?
>>
>> I googled but could not find exact idea.
>>
>> -Rohit
>
>To do that you would need to record those sounds and play back the samples
>(under Windows these would be stored in a .wav file) using 1-bit PWM.
>Haven't done it myself, but I've seen C source code which plays sounds
>through the PC speaker, which uses similar technology. Google for that.
Not really required. For a chirping bird, for example, try a couple of
short bursts of a high-pitched tone followed by a slightly longer burst
of a lower tone, the whole sequence repeating four or five times. A
machine-gun-ish sound could be two bursts in rapid succession, low and
lower, and repeat.
--
Rich Webb Norfolk, VA