简体   繁体   中英

programmatically create a pad sound

Okay this one may be a bit out from left field, but I'm going to try anyways.

A pad is a sort of ambient electronic sound that kind of 'hums'. Something like this .

How can I produce this in code? Using either Processing, OpenFrameworks, C, Objective-C or C++. Keep in mind I haven't been programming for that long.

I will be very impressed if this results in an answer!

Okay... Go!

I've never heard the term "pad" as applied here, but it sounds like a synth organ sound, playing major chords.

As a start, to represent a single note, you could generate sin waves at the fundamental frequency of the note (say 440Hz if we're talking about an A Major) and the next few multiples of that (880, 1760, 3520) and sum them with some (diminishing) weights. Then add in the other notes of the chord (C# and E) rendered in the same way.

If this is sounding useful to you so far, I can expand if needed.

EDIT: By "some (diminishing) weights", I meant adding the overtones times some amplification, eg

F = 440;  // Hz
tone[t] = A * sin(t/F) + B * sin(t/(2*F)) + C * sin(t/(3*F)); // + etc, perhaps

where, perhaps,

A = 1.0;
B = 1.0/2.0;
C = 1.0/3.0;

or some such thing.

For an ADSR filter (look that up), you'll multiply the generated waveform by an amplification that increases from 0 to 1 during the "attack" period you choose, then drops during the "decay" period to some number you choose (perhaps 0.7), then drops to 0 linearly when you "release" the sustained note.

For echo/reverb, you can add the waveform back into itself with some delay, eg

D = 4410;  // 10 msec at 44.1 kHz., as an example value
tone[t] += 0.5 * tone[t-D];

There's explaination of pad synthesis:

http://zynaddsubfx.sourceforge.net/doc/PADsynth/PADsynth.htm

I can't help you out with concrete code examples, but I'd say something akin to this sound sample of yours could be done with FM (Frequency Modulation) synthesis .

Before you write any code, you might want to download any software FM synthesizer from the internet (there are many freely available, some as standalone applications, some as VST plug-ins) and experiment a little, and if you can produce the sound you want, write the corresponding code. (By that time, chances are that you will know what combination of oscillators, frequencies etc. you need.)

If you are not expereianced in sound programming, you should imho take a look at java sound, since its really easy to learn and use. I know you have tagged C* but i don't know if there is such a easy API or so.

Creating a sound is basiclly what grumdrig said, you "Just" have to combine differnt waves in such a manner that you like the sound. ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM