Csound Csound-dev Csound-tekno Search About

Create Halloween Sound Effects with Spatializer Orc/Sco

Date1998-10-22 16:43
FromHans Mikelson
SubjectCreate Halloween Sound Effects with Spatializer Orc/Sco
Hidyho Csounders,

If you are like me then you have been busy decorating the outside of your
house with cob-webs, skeletons, dummies, transforming the front yard into a
graveyard, installing motion sensor triggered special effects, smoke
machines, black lights and strobe lights.  No Halloween house would be
complete without some spooky sound effects.

First go pick some spooky sounds from your local internet haunted sound
depot:

http://www.geocities.com/Heartland/Meadows/6158/story/hhsound.html

This is a good start but mono sounds are not going to cut it for Halloween.
You want owls hooting in the tree above your head, wolves howling all around
you, cackling witches whizzing past on broomsticks, organs playing in a
cathedral and beasts trying to bite your head off.

Now you can animate those dull lifeless Halloween sounds with my handy-dandy
spatial audio generator to make truly bone-chilling, spine-tingling effects.
Merely insert your soundin.? file into the spatializer, specify x, y
coordinate paths and let your sounds come alive:

; ORCHESTRA
;---------------------------------------------------------------------------
-------
; Spatial Audio
; Coded by Hans Mikelson October 1998
; This spatial audio system included the following features:
;
;  1. Moving sound source with table supplied moving X and Y coordinates
;  2. Volume decreases as 1/r^2
;  3. Filtering of sound due to air absorption
;  4. Doppler effect due to moving sound
;  5. Simplified HRTF for head shadow filtering
;  6. Inter ear time delay
;  7. Speaker cross-talk cancellation based on both inter ear time delay &
head shadowing
;---------------------------------------------------------------------------
-------
sr=44100
kr=22050
ksmps=2
nchnls=2
zakinit 30,30
;---------------------------------------------------------------------------
-------
; Disk Input Mono
;---------------------------------------------------------------------------
-------
        instr  4
iamp    =      p4
irate   =      p5
isndin  =      p6
ioutch1 =      p7
ain1    diskin isndin, irate
        zawm   ain1, ioutch1
        endin
;---------------------------------------------------------------------------
-------
; Disk Input Stereo
;---------------------------------------------------------------------------
-------
        instr  5
iamp    =      p4
irate   =      p5
isndin  =      p6
ioutch1 =      p7
ioutch2 =      p8
ain1, ain2 diskin isndin, irate
        zawm   ain1, ioutch1
        zawm   ain2, ioutch2
        outs   ain1*iamp, ain2*iamp
        endin

;---------------------------------------------------------------------------
-------
; Spatial Audio
; Coded by Hans Mikelson October 1998
;---------------------------------------------------------------------------
-------
        instr     11
idur    =         p3            ; Duration
iamp    =         p4            ; Amplitude
iexl    =         p5            ; Fixed left ear location X coordinate
iexr    =         iexl+.23      ; Fixed right ear location X coordinate
iey     =         p6            ; Fixed ear location Y coordinate (facing +Y
axis)
isxtab  =         p7            ; Moving source table for X coordinate in m
isytab  =         p8            ; Moving source table for Y coordinate in m
iinch   =         p9            ; Audio input channel
ihrtabl =         p10           ; Head shadowing filter for left ear
ihrtabr =         p11           ; Head shadowing filter for right ear
imax    =         500           ; Maximum delay time in ms
ipi     =         3.14159265    ; Pi
ics     =         .333          ; Approx. speed of sound in m/ms
kamp    linseg    0, .002, iamp, idur-.004, iamp, .002, 0 ; Declick
Enevelope
ksx     oscil     1, 1/idur, isxtab                       ; Moving Source X
ksy     oscil     1, 1/idur, isytab                       ; Moving Source Y
ksmexl  =         ksx-iexl                                ; Delta X left
ksmexr  =         ksx-iexr                                ; Delta X right
ksmey   =         ksy-iey                                 ; Delta Y
kdistl  =         sqrt(ksmexl*ksmexl+ksmey*ksmey)         ; Distance from
left ear to source
kdistr  =         sqrt(ksmexr*ksmexr+ksmey*ksmey)         ; Distance from
right ear to source
kdistlnz=         (kdistl==0 ? 1 : kdistl)                ; Avoid divide by
zero problem
kdistrnz=         (kdistr==0 ? 1 : kdistr)                ; Avoid divide by
zero problem
kangl   =         cosinv(ksmexl/kdistlnz)                   ; Get the
magnitude of the angle (0 to Pi)
kangr   =         cosinv(ksmexr/kdistrnz)                   ; Get the
magnitude of the angle (0 to Pi)
ksmeynz =         (ksmey==0 ? 1 : ksmey)                  ; Make sure it is
not zero
ksign   =         ksmeynz/abs(ksmeynz)/2/ipi              ; Get the sign
kanglel =         kangl*ksign                             ; Get the true
angle -Pi to Pi
kangler =         kangr*ksign                             ; Get the true
angle -Pi to Pi
kdd4l   =         kdistl/4                                ; Factor for
distance and air absorption
kdd4r   =         kdistr/4                                ; Factor for
distance and air absorption
ain     zar       iinch                                   ; Input audio
adoppl  vdelay    ain/(1+kdd4l*kdd4l), kdistl/ics, imax   ; Volume decreases
as distance^2.
adoppr  vdelay    ain/(1+kdd4r*kdd4r), kdistr/ics, imax   ; Volume decreases
as distance^2.
                                                          ; arrival time is
delayed by speed of sound, doppler effect
afltail butterlp  adoppl, 20000/(1+kdd4l)                 ; Air absorption
of distant sound
afltair butterlp  adoppr, 20000/(1+kdd4r)                 ; Air absorption
of distant sound
khrtfl  tablei    kanglel, ihrtabl, 1, .5                 ; Get the "poor
man's" HRTF for left ear
khrtfr  tablei    kangler, ihrtabr, 1, .5                 ; Get the "poor
man's" HRTF for right ear
ahrtfl  butterlp  afltail, khrtfl                         ; Apply the filter
for head shadowing left ear
ahrtfr  butterlp  afltair, khrtfr                         ; Apply the filter
for head shadowing right ear
asctcl  butterlp  ahrtfl, 8000                            ; Simplified head
shadowing for speaker cross-talk
asctcr  butterlp  ahrtfr, 8000                            ; Simplified head
shadowing for speaker cross-talk
asctcdl delay     asctcl, .0003                           ; Speaker
cross-talk cancellation delay left
asctcdr delay     asctcr, .0003                           ; Speaker
cross-talk cancellation delay right
        outs      (ahrtfl-asctcdr)*kamp, (ahrtfr-asctcdl)*kamp ; Cancel
speaker cross-talk and ouput

        zacl      iinch, iinch                            ; Clean up the zak
channel
        endin

; SCORE
;   Sta  Dur   Amp  Pitch  SoundIn  OutCh
i4  0.0  2.61  0.0  1      1        1
i4  3.0  1.52  0.0  1      3        2
i4  4.0  4.38  0.0  1      2        1
i4  8.0  1.86  0.0  1      4        1
i4  6.0  5.44  0.0  1      5        2

f4 0 1024 -7  16000 128 12000 384  3000 128  8000 256 20000 256 16000 ; HRTF
Left
f5 0 1024 -7   8000 128  3000 384 12000 128 16000 256 20000 256  8000 ; HRTF
Right
f10 0 1024 -7    12  512  25  512 15                   ; Moving Source X
f11 0 1024 -7    7   256  7   256  8  256   9 256  15  ; Moving Source Y
f12 0 1024 -7    18  512  23  512 15                   ; Moving Source X
f13 0 1024 -7    18  256   9  256  8  256   9 256  15  ; Moving Source Y
; 2D Echos
;    Sta  Dur  Amp  EarX  EarY  SourceX  SourceY  InCh  HRTFL  HRTFR
i11  0.0  10.0 .5   20    10    10       11       1     4      5
i11  3.0  10.0 .5   20    10    10       12       2     4      5