Monday, July 10, 2017

ex1A01_1. Aliasing

# ex1A01_1.py
# Aliasing

from moduleCsound import *

add("""
<CsoundSynthesizer>
<CsInstruments>
""")

# From now on we will use this instead:
# tags(1)

add("""
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
""")

# From now we will use this instead:
# header(ksmps=32)
# defauls for header are sr=44100, ksmps=10, nchnls=2, 0dbfs=1
# usually we overwrite only ksmps

# instrument 1
add("""
instr 1
asig    oscils  .2, p4, 0
        outs    asig, asig
endin
""")

add("""
</CsInstruments>
<CsScore>
""")

# From now on we will use this instead:
# tags(2)

add("""
i 1 0 2 1000 ;1000 Hz tone
i 1 3 2 43100 ;43100 Hz tone sounds like 1000 Hz because of aliasing
""")

add("""
</CsScore>
</CsoundSynthesizer>
""")

# From now on we will use this instead:
# tags(3)

writeRun(__file__)

No comments:

Post a Comment

ex3A05. Audio Vector