User:Albert Jongstra/technicalcourse

From XPUB & Lens-Based wiki

TECHNICAL COURSE

SEQUENTIAL LOOP

from os import system

for i in range(1):
    system("cat snare05.raw >> song.raw")
    system("cat snare05.raw >> song.raw")
    system("cat snare05.raw >> song.raw")
    system("cat snare05.raw >> song.raw")
    system("cat loop06.raw >> song.raw")
    system("cat loop7.raw >> song.raw") 
    system("cat snare05.raw >> song.raw")
    system("cat snare05.raw >> song.raw")   
    system("cat snare05.raw >> song.raw")


system("sox --rate 44100 --bits 16 --channels 2 --encoding signed-integer song.raw song.wav")
system("rm song.raw")
system("play song.wav")


NESTED LOOP

#!/bin/bash

# nested-loop.sh Nested "for" loops.

outer=1             # Set outer loop counter

# Beginning of outer loop
for a in 1 2 3 4 5
do
    echo "pass $outer in outer loop."
    play -c1 -r8000 -n synth 0.50 sine 220 vol 0.7
    play -c1 -r8000 -n synth 0.25 square 220 vol 0.7
    play -c1 -r8000 -n synth 0.25 noise 220 vol 0.7
    play -c1 -r8000 -n synth 0.50 sine 220 vol 0.7
    inner=1         # Reser inner loop counter

    # ===========================================
    # Beginning of innner loop.
    for b in 1 2 3 
    do
        play -c1 -r8000 -n synth 0.25 noise 220 vol 0.7
        play -c1 -r8000 -n synth 0.50 sine 220 vol 0.7
        play -c1 -r8000 -n synth 0.2 pinknoise 220 vol 1.0
        play -c1 -r8000 -n synth 0.60 square 55 vol 0.7 
        let "inner+=1" # Increment inner loop counter
    done
    # End of inner loop.
    # ===========================================

    let "outer+=1"     # Increment outer loop counter.
    echo               # Space between outputr in pass of outer loop.
done
# End of outer loop.

# combine all the individual files to a single file

exit 0




Attachments