You are on page 1of 4

global_tempo = 160.

0
global_time = 0.0
global_active_track = 0
global_measure_start_time = 0.0

kick = 1
snare = 2
hat = 3
sticks = 4
cabasa = 5
low_tom = 6
mid_tom = 7
hi_tom = 8

kick_track_number = 2-1 # Track 2


snare_track_number = 3-1 # Track 3
closed_hat_track_number = 4-1 # Track 4
sticks_track_number = 5-1
cabasa_track_number = 6-1
low_tom_track_number = 7-1
mid_tom_track_number = 8-1
hi_tom_track_number = 9-1

start_drum_track = 2-1 # Track 2


end_drum_track = 9-1 # Track 9

closed_hat_file = "C:/ees/Samples/Closed Hats/Closed Hi Hat.wav"


kick_file = "C:/ees/Samples/Kicks/Kick.wav"
snare_file = "C:/ees/Samples/Snares/Snare.wav"
cabasa_file = "C:/ees/Samples/Cabasas/Cabasa.wav"
sticks_file = "C:/ees/Samples/Sticks/Sticks.wav"
low_tom_file = "C:/ees/Samples/Toms/Low Tom.wav"
mid_tom_file = "C:/ees/Samples/Toms/Mid Tom.wav"
hi_tom_file = "C:/ees/Samples/Toms/Hi Tom.wav"

def reset_cursor():
global global_time
global_time = 0.0
set_cursor()

def set_tempo(local_tempo):
global global_tempo
global_tempo = local_tempo

def set_cursor():
global global_time
RPR_SetEditCurPos(global_time,0,0)

def clear_drums():
RPR_Main_OnCommand(40769,0) # Unselect everything.
for i in range(start_drum_track,end_drum_track):
RPR_SetTrackSelected(RPR_GetTrack(0,i),1)
RPR_Main_OnCommand(40421,0) # Select all items in track
RPR_Main_OnCommand(40184,0) # Remove items, no prompting

def set_active_track(track_number):
for i in range(start_drum_track,end_drum_track):
RPR_SetTrackSelected(RPR_GetTrack(0,i),0)
RPR_SetTrackSelected(RPR_GetTrack(0,track_number),1)
global global_active_track
global_active_track = RPR_GetTrack(0,track_number)

def sound_kick():
set_active_track(kick_track_number)
insert_media(kick_file)

def sound_snare():
set_active_track(snare_track_number)
insert_media(snare_file)

def sound_hat():
set_active_track(closed_hat_track_number)
insert_media(closed_hat_file)

def sound_sticks():
set_active_track(sticks_track_number)
insert_media(sticks_file)

def sound_cabasa():
set_active_track(cabasa_track_number)
insert_media(cabasa_file)

def sound_low_tom():
set_active_track(low_tom_track_number)
insert_media(low_tom_file)

def sound_mid_tom():
set_active_track(mid_tom_track_number)
insert_media(mid_tom_file)

def sound_hi_tom():
set_active_track(hi_tom_track_number)
insert_media(hi_tom_file)

def insert_media(file):
RPR_InsertMedia(file,0)

def set_last_volume(volume_multiplier): # Of last media item added


RPR_Main_OnCommand(40289,0) # Unselect all items
RPR_Main_OnCommand(40421,0) # Select all items in track
global global_active_track
current_volume = RPR_GetTrackUIVolPan(global_active_track, 0, 0)[2]

RPR_SetMediaItemInfo_Value(RPR_GetSelectedMediaItem(0,RPR_CountSelectedMediaItems(0
)-1),"D_VOL",current_volume*volume_multiplier)

def set_last_pitch(pitch): # Of last media item added


RPR_Main_OnCommand(40289,0) # Unselect all items
set_cursor()
#RPR_Main_OnCommand(41127,0) # Select next adjacent non-overlapping item
RPR_Main_OnCommand(40102,0) # Move cursor left, creating time selection
RPR_Main_OnCommand(40103,0) # Move cursor right, creating time selection
RPR_Main_OnCommand(40103,0) # Move cursor right, creating time selection
RPR_Main_OnCommand(40718,0) # Select all items on selected tracks in current
time selection
if(pitch > 0):
for i in range(0,pitch):
RPR_Main_OnCommand(40204,0) # Pitch item up one semitone
elif(pitch < 0):
for i in range(0,-pitch):
RPR_Main_OnCommand(40205,0) # Pitch item down one semitone

RPR_Main_OnCommand(40635,0) # Remove time selection

def goto_beat(beat):
global global_time
global global_measure_start_time
global global_tempo
global_time = global_measure_start_time + ((60 * (beat-1)) / global_tempo)
set_cursor()

def increment_measure():
global global_time
global global_measure_start_time
global global_tempo
global_measure_start_time = global_measure_start_time + ((60 * 4) /
global_tempo)

def hit(sound,beat,volume,pitch):
goto_beat(beat)

if(sound == kick):
sound_kick()
elif(sound == snare):
sound_snare()
elif(sound == hat):
sound_hat()
elif(sound == sticks):
sound_sticks()
elif(sound == cabasa):
sound_cabasa()
elif(sound == low_tom):
sound_low_tom()
elif(sound == mid_tom):
sound_mid_tom()
elif(sound == hi_tom):
sound_hi_tom()

if(volume != 1.0):
set_last_volume(volume)

if(pitch != 0.0):
set_last_pitch(pitch)

def step(beats): # 1.0 = 1 beat


global global_time
global global_tempo
global_time = global_time + ((60.0 * beats) / global_tempo)

def measure_1():
hit(kick, 1.0, 1.0, 0)
hit(hat, 1.0, 1.0, 0)
hit(cabasa,1.5, 1.0, 0)
hit(hat, 2.0, 1.0, 0)
hit(kick, 2.5, 1.0, 0)
hit(snare, 3.0, 1.0, 0)
hit(cabasa,3.5, 1.0, 0)
hit(snare, 4.0, 1.0, 0)
hit(hat, 4.0, 1.0, 0)

def measure_2():
hit(cabasa,0.5, 1.0, 0)
hit(kick, 1.0, 1.0, 0)
hit(hat, 1.0, 1.0, 0)
hit(kick, 1.5, 1.0, 0)
hit(hat, 2.0, 1.0, 0)
hit(kick, 2.5, 1.0, 0)
hit(cabasa,2.5, 1.0, 0)
hit(snare, 3.0, 1.0, 0)
hit(hat, 4.0, 1.0, 0)

def intro():
for i in range(0,30):
measure_1()
increment_measure()
measure_2()
increment_measure()

def count_in():
hit(sticks,1.0,1.0,0.0)
hit(sticks,3.0,1.0,0.0)
increment_measure()
hit(sticks,1.0,1.0,0.0)
hit(sticks,3.0,1.0,0.0)
increment_measure()

clear_drums()

count_in()
intro()
# verse_1()
# chorus()
# verse_2()
# chorus()
# break_1()
# verse_3()
# chorus()
# chorus()
# outro()

reset_cursor()

You might also like