22.02.2017 Views

-ORIENTED

MagPi54

MagPi54

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ADDITIVE SYNTHESIS<br />

Tutorial<br />

Language<br />

>RUBY<br />

Left Combine<br />

sounds to make<br />

new ones with<br />

additive synthesis<br />

Amplitude shaping<br />

nother wy in whih we n finey rt our ound i<br />

to ue dierent enveope nd option or eh ynth<br />

trigger. or empe thi wi ow you to me ome<br />

pet o the ound peruive nd other pet ring<br />

out or period o time.<br />

oupe o ow ine wve to give the ound ome <br />

nd depth. iny we ue define to wrp our ode in <br />

untion whih we n then ue to py meody. ry<br />

pying your own meody nd o meing round with<br />

the ontent o the :bell untion unti you rete<br />

your own ry ound to py with<br />

detune = 0.1<br />

synth :square, note: :e1, release: 2<br />

synth :square, note: :e1 + detune, amp: 2,<br />

release: 2<br />

synth :gnoise, release: 2, amp: 1, cutoff: 60<br />

synth :gnoise, release: 0.5, amp: 1, cutoff: 100<br />

synth :noise, release: 0.2, amp: 1, cutoff: 90<br />

n the empe ove we hve mied in noiy<br />

peruive eement to the ound ong with ome<br />

more peritent ground ruming. hi w<br />

hieved firty y uing two noie ynth with<br />

midding cutoff vue 90 nd 100 uing hort<br />

release time ong with noie with onger release<br />

time ut with ow cutoff vue whih me the<br />

noie e rip nd more rumy.<br />

Bringing it all together<br />

et omine thee tehniue to ee i we n<br />

ue dditive ynthei to rerete i e ound.<br />

eve roen thi empe into our etion. irty<br />

we hve the hit etion whih i the initi onet<br />

prt o the e ound nd o ue hort enveope<br />

e.g. release: o round 0.1. et we hve the<br />

ong ringing etion or whih were uing the pure<br />

ound o the ine wve. otie tht were oten<br />

inreing the note y roughy 12 nd 24 whih i the<br />

numer o note in n otve. eve o thrown in <br />

define :bell do |n|<br />

# Triangle waves for the ‘hit’<br />

synth :tri, note: n - 12, release: 0.1<br />

synth :tri, note: n + 0.1, release: 0.1<br />

synth :tri, note: n - 0.1, release: 0.1<br />

synth :tri, note: n, release: 0.2<br />

# Sine waves for the ‘ringing’<br />

synth :sine, note: n + 24, release: 2<br />

synth :sine, note: n + 24.1, release: 2<br />

synth :sine, note: n + 24.2, release: 0.5<br />

synth :sine, note: n + 11.8, release: 2<br />

synth :sine, note: n, release: 2<br />

# Low sine waves for the bass<br />

synth :sine, note: n - 11.8, release: 2<br />

synth :sine, note: n - 12, release: 2<br />

end<br />

# Play a melody with our new bell!<br />

bell :e3<br />

sleep 1<br />

bell :c2<br />

sleep 1<br />

bell :d3<br />

sleep 1<br />

bell :g2<br />

raspberrypi.org/magpi February 2017<br />

61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!