startPitch = 0 startPitchBass = 1 affineGroup = [aT(u, a) for u in [1, 5, 7, 11] for a in range(12)] affineGroupIndex = [(u, a) for u in [1, 5, 7, 11] for a in range(12)] affineGroupByOrder = [(orderMul(x), x) for x in affineGroupIndex] print(affineGroupByOrder) twoLoops = [x for o, x in affineGroupByOrder if o == 2] threeLoops = [x for o, x in affineGroupByOrder if o == 3] fourLoops = [x for o, x in affineGroupByOrder if o == 4] print(len(twoLoops)) print(len(fourLoops)) countBass = 0 s = Session(tempo=120, default_soundfont="/usr/share/sounds/sf2/FluidR3_GM.sf2" ) #.run_as_server() s.print_available_midi_output_devices() tracks = construct_ensemble() for t in tracks: s.add_instrument(t) counters = dict(zip(range(48), 48 * [0])) def updateCounterForRect(rectangleNumber, plusOne=True): global counters if plusOne:
def on_press(key): try: global rate rate = 1 + int(str(key).replace("\'", "")) print("New rate is ", rate) except ValueError: # ignore key presses that don't correspond to number keys pass # Collect events until released Listener(on_press=on_press).start() s = Session() piano = s.new_part("piano", num_channels=40) def do_chords(clock): while True: if rate != clock.rate: clock.rate = rate piano.play_chord( [random.random() * 24 + 60, random.random() * 24 + 60], 1.0, 1.0) def do_fast_notes(clock): while True:
from edopi import TonalSystem, Scale, transpose_to_octave from scamp import Session import random as rd z = TonalSystem(20) z.set_generator(11) diatonic = z.diatonic_scale() midi_classes = diatonic.elements #[0, 2, 4, 6, 8, 9, 11, 13, 15, 17, 19] midi_pitches = diatonic.midi_pitch_classes #[0, 0.6, 1.2, 1.8, 2.4, 3.0, ..., 11.4] central_note = 100 microtonal_melody_1 = [rd.choice(midi_classes) for _ in range(24)] microtonal_melody_2 = [rd.choice(midi_pitches) for _ in range(24)] microtonal_melody_3 = [diatonic.next(central_note, rd.randint(-5, 5)) for _ in range(24)] print([z.midi_pitch(e) for e in microtonal_melody_3]) #SCAMP s = Session() p = s.new_part('piano') s.start_transcribing() for pc in microtonal_melody_1: p.play_note(z.midi_pitch(pc, 4), 0.8, 1/3) for pc in microtonal_melody_2: p.play_note(transpose_to_octave(pc, 2), 0.8, 1/3) for pitch in microtonal_melody_3: p.play_note(z.midi_pitch(pitch), 0.8, 1/3)
startPitchBass = 1 affineGroup = [aT(u, a) for u in [1, 5, 7, 11] for a in range(12)] affineGroupIndex = [(u, a) for u in [1, 5, 7, 11] for a in range(12)] affineGroupByOrder = [(orderMul(x), x) for x in affineGroupIndex] print(affineGroupByOrder) twoLoops = [x for o, x in affineGroupByOrder if o == 2] threeLoops = [x for o, x in affineGroupByOrder if o == 3] fourLoops = [x for o, x in affineGroupByOrder if o == 4] print(len(twoLoops)) print(len(fourLoops)) countBass = 0 #s = Session(default_soundfont_preset="path/to/soundfont.sf2") #s = Session(default_soundfont="/usr/share/sounds/sf2/FluidR3_GM.sf2",tempo=130) s = Session(tempo=120) tracks = construct_ensemble() #s.print_default_soundfont_presets() #print(dir(s)) #s.print_available_midi_output_devices() #drums = s.new_part("Concert Bass Drum") def play_notes_for_first(numNotes, duration): global countBass, countClick, tracks, currentCounter, startPitchClef, oneOctave, twoLoops, instrument, affineGroupIndex, bass print("playing first", oneOctave[startPitchClef]) for k in range(numNotes):
from scamp import Session, Clock s = Session() piano = s.new_part("piano") # trombone = s.new_part("trombone") # When a function is forked, it is run on a child clock of the process forking it. # This child clock can be passed as the first argument and then manipulated. def trumpet_part(clock: Clock): # play eighth notes for three beats while s.beat() < 3: piano.play_note(72, 1, 0.5) # tell the clock for this child process to slow down to 1/2 speed over six beats in the parent process # metric_phase_target of 0 ensures that we reach that we land perfectly on a beat clock.set_rate_target(0.5, 6, duration_units="time", metric_phase_target=0) # keep playing eighth notes until 12 beats pass in the parent session while s.beat() < 12: piano.play_note(72, 1, 0.5) # Have the session as a whole speed up to 100 BPM over the first nine beats s.set_tempo_target(100, 9) # Fork the trumpet part as a child process. It will be influenced both by its own tempo and that of the session # s.fork(trumpet_part) # s.start_transcribing() # Play quarter notes for 12 beats # while s.beat() < 12:
# This program is free software: you can redistribute it and/or modify it under the terms of # # the GNU General Public License as published by the Free Software Foundation, either version # # 3 of the License, or (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # See the GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License along with this program. # # If not, see <http://www.gnu.org/licenses/>. # # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # from scamp import Session import random s = Session() piano = s.new_part("piano") def do_chords(): while True: piano.play_chord([random.random()*24 + 60, random.random()*24 + 60], 1.0, 1.0) def do_fast_notes(): while True: piano.play_note(random.random()*24 + 80, 1.0, 0.1) s.fork(do_chords) s.fork(do_fast_notes)
import pygame import time import pygame.locals as locals from scamp import Session # sys.path.insert(0, "src/") from src.channel import channel from src.constant import TIME_POS, DURATION_MAX, \ running, playButton, recordingButton, \ background, back_button, fonts instruments = ["piano", "guitar", "trumpet", "violin"] screen = pygame.display.set_mode((800, 480)) s = Session() chan = [channel(s, instrument=x) for x in instruments] chan[0].select(True) selected_chan = 0 startTime = time.time() timeElapsed = 0 keys = { pygame.locals.K_a: 48, 97: 60, 113: 72, pygame.locals.K_TAB: 49, 122: 61, 115: 73, 9: 50,
startPitchBass = 1 affineGroup = [aT(u,a) for u in [1,5,7,11] for a in range(12)] affineGroupIndex = [(u,a) for u in [1,5,7,11] for a in range(12)] affineGroupByOrder = [ (orderMul(x),x) for x in affineGroupIndex] print(affineGroupByOrder) twoLoops = [x for o,x in affineGroupByOrder if o==2] threeLoops = [x for o,x in affineGroupByOrder if o==3] fourLoops = [x for o,x in affineGroupByOrder if o==4] print(len(twoLoops)) print(len(fourLoops)) countBass = 0 s = Session(tempo=120,default_soundfont=sf).run_as_server() s.print_available_midi_output_devices() s.print_available_midi_input_devices() tracks = construct_ensemble(sf) print(len(tracks)) for t in tracks: s.add_instrument(t) piano = s.new_part("Acoustic Bass") #piano = s.new_part("Concert Bass Drum") s.add_instrument(piano)