fractal_multi_track.py 1.08 KB
Newer Older
ecofractal's avatar
ecofractal committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
'''
Multitrack Code - fractaL April 15th 2019

Here, you can find the code to build a multiple MIDI instrument sound using
different environmental variables.

@author: smjacques
'''
import pandas as pd
import fractaL.core as fractal


#import data in a dataframe(df) format
df = pd.read_csv('sample_data/multilong.csv')

test = fractal.normalize_climate_multi(df)


# Let's add some instruments to each track!
instruments_to_add = [
    'violin', 'hi wood block', 'melodic tom'
]

multitrack_data_with_instruments = []
for index, track in enumerate(test):
    multitrack_data_with_instruments.append([instruments_to_add[index]] + track)

# test a drum track with a solid beat
max_number_of_beats = multitrack_data_with_instruments[1][-2][1]

bass_drum = []
for beat in range(0, int(max_number_of_beats + 1)):
   bass_drum.append((beat, 1)) 

beat_track = ['bass drum 1'] + bass_drum
multitrack_data_with_instruments.append(beat_track)

print(multitrack_data_with_instruments)

fractal.play_midi_from_data(multitrack_data_with_instruments,
                            track_type='multiple', key='f_major')