def test_simple_soundwaves(self): # Get all data place = "Madrid" mad2t = get(c.T, location=place) madp = get(c.P, location=place) madw = get(c.W, location=place) madc = get(c.C, location=place) # write orchestra + score duration = 30 points = 16777216 oscillator = orchestra.oscillator1(points) score = [ "f1 0 8192 10 1 ; Table containing a sine wave.", gen08(2,mad2t,number_of_points=points,comment="Weather parameter table 2"), gen08(3,madp,number_of_points=points,comment="Weather parameter table 3",), gen08(4,madw,number_of_points=points,comment="Weather parameter table 4"), gen08(5,madc,number_of_points=points,comment="Weather parameter table 5"), "i1 0 %s 10000 2 ; " % duration, "i1 0 %s 5000 3 ; " % duration, "i1 0 %s 5000 4 ; " % duration, "i1 0 %s 5000 5 ; " % duration ] output.write_and_play(output.get_csd([oscillator],score))
def play(self): scale = cnc.SCALES["major"] for n in scale: n.octave += 2 notes = shep.generate_list(scale, length=30, levels=10) log.debug("Notes: %s " % (notes)) step = 0.25 duration = step / 2.0 time = 1 score = [] for chord in notes: score.append("; Writing out %s" % chord) for note in chord: amp = note[0] pitch = "%s.%02d" % (note[1].octave, note[1].semitones) score.append("i1 %s %s %s %s ; %s " % (time, duration, amp * 5000, pitch, note)) time += step #pluck = orchestra.wgpluck2(instrument_number=1,krefl=0.95) #pluck = orchestra.wgpluck(instrument_number=1) score.insert( 0, "f2 0 16384 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111 ; Sawtooth" ) score.insert(0, "f 1 0 16384 10 1") pluck = orchestra.basic_wave(instrument_number=1) output.write_and_play(output.get_csd([pluck], score)) pluck = orchestra.basic_wave(instrument_number=1, function_number=2) output.write_and_play(output.get_csd([pluck], score))
def no_test_scale_wgpluck(self): notes = gen.get_notes_following_spline(get(td.T, location='Madrid'), td.T, cnc.SCALES["major"], n.find("D")) plucker = orchestra.wgpluck(instrument_number=1, function_number=1) score = [ "f 1 0 16384 10 1" ] # wgpluck requires an excite function https://csound.github.io/docs/manual/wgpluck.html for i in range(0, len(notes)): score.append("i1 %s 1 30000 %s.%02d" % (i, notes[i].octave, notes[i].semitones)) output.write_and_play(output.get_csd([plucker], score))
def no_test_scale_wgpluck2(self): """ wgpluck seems to sound a bit better, so let's mothball this for a while""" notes = gen.get_notes_following_spline(get(td.T, location='Madrid'), td.T, cnc.SCALES["major"], n.find("D")) plucker = orchestra.wgpluck2(instrument_number=1) score = [] for i in range(0, len(notes)): score.append("i1 %s 1.25 30000 %s.%02d" % (i, notes[i].octave, notes[i].semitones)) output.write_and_play(output.get_csd([plucker], score))
def test_simple_soundwaves(osc=1, duration=30): """ Play a sine wave for each of the parameters of Madrid in 2014. Depending on the osc parameter 1: Play four sine waves following each of 2t, p, w, c 2: Play two sine waves, modulated in frequency and amplitude, the first by 2t and w, the second by p and c 3: Play two sine waves, each consisting in two oscillators with a base frequency controlled py t or c, where the second oscillator of the instruments is p or w cycles off the main oscillator """ # Get all data loc = "Madrid" mad2t = get(td.T, location=loc) madp = get(td.P, location=loc) madw = get(td.W, location=loc) madc = get(td.C, location=loc) # write orchestra + score points = 16777216 if osc == 1: oscillator = orchestra.oscillator1(points, instrument_number=1) events = [ "i1 0 %s 10000 2 ; " % duration, "i1 0 %s 5000 3 ; " % duration, "i1 0 %s 5000 4 ; " % duration, "i1 0 %s 5000 5 ; " % duration ] elif osc == 2: oscillator = orchestra.oscillator2(points, instrument_number=2) events = [ "i2 0 %s 10000 2 4; " % duration, "i2 0 %s 10000 3 5; " % duration, ] elif osc == 3: oscillator = orchestra.oscillator_dual(points, instrument_number=3) events = [ "i3 0 %s 10000 2 3 ; " % duration, "i3 0 %s 10000 5 4 ; " % duration, ] score = [ "f1 0 8192 10 1 ; Table containing a sine wave.", gen08(2, mad2t, number_of_points=points, comment="Weather parameter table 2"), gen08( 3, madp, number_of_points=points, comment="Weather parameter table 3", ), gen08(4, madw, number_of_points=points, comment="Weather parameter table 4"), gen08(5, madc, number_of_points=points, comment="Weather parameter table 5") ] score += events output.write_and_play(output.get_csd([oscillator], score))