def __init__(self): address = "127.0.0.1" port = 8008 self.osc = OSCClient(address, port) self.text = "" import settings import cooked_files_handler self.settings = settings.Settings() self.songs_models = cooked_files_handler.CookedFilesHandler( self.settings) self.songs_models.prepare_songs_models_paths()
def manual_init_song_model(self, song_file, model_file): self.songs_models = cooked_files_handler.CookedFilesHandler( self.settings, False) self.songs_models.model_paths = [model_file] self.songs_models.song_paths = [song_file] self.songs_models.names_for_debug = [song_file] self.model_i = 0 self.song_i = 0 print( "We have loaded these songs and models (ps: their order should match, please name them accordingly):" ) print("models:") for m in self.songs_models.model_paths: print(m) print("songs:") for s in self.songs_models.song_paths: print(s) # Load model weights & song impulses t_load_model = timer() self.load_weights(model_i=self.model_i, mode='graph') t_load_model = timer() - t_load_model t_load_song = timer() if self.preloaded_impulses is None: print("Also have to load the song") # this happens in Regular load mode (aka with older models) self.load_impulses( song_i=self.song_i ) # no need we have the first one with the weights already self.change_impulse(interactive_i=self.interactive_i) t_load_song = timer() - t_load_song # print("Model loaded in", t_load_model, ", song loaded in", t_load_song, "(sec).") print("Model and song loaded in", t_load_model, "(sec).")
def __init__(self, parent=None): super(GUI_OSC, self).__init__(parent) self.setWindowTitle("Interactive Music Generation") self.font_size = 14 self.verbose = 1 # 2 = too much, 1 = enough, 0 will be silent self.last = None # Init OSC - output address = "127.0.0.1" port = 8008 self.osc = OSCClient(address, port, encoding='utf8') self.text = "" # Init MIDI controller - input device_id = 1 import platform if 'linux' in platform.system().lower(): # linux / windows device_id = 3 print_device_info() function_to_call_pad_click = self.midi_bound_pad_click function_to_call_xy_pad = self.midi_bound_xy_pad midi_controller = MIDI_Input_Handler(device_id, function_to_call_pad_click, function_to_call_xy_pad) threading.Thread(target=midi_controller.input_loop, args=[]).start() print("Initiated midi controller! device_id=", device_id) # empty saved positions for midi bound clicks self.saved_positions = {} self.load_midi_positions() import settings import cooked_files_handler self.settings = settings.Settings() self.songs_models = cooked_files_handler.CookedFilesHandler( self.settings) self.songs_models.prepare_songs_models_paths() # Init on screen GUI - input layout = QVBoxLayout() style = "QWidget {font-size: " + str(self.font_size) + "pt;}" hbox_model_select = QHBoxLayout() text_model_select = QLabel() text_model_select.setText("Model selection:") text_model_select.setStyleSheet(style) model_select = QComboBox() for model_path in self.songs_models.model_paths: just_model = model_path.split("/")[-1] just_model = just_model[0:min(len(just_model), 30)] model_select.addItem(just_model) self.model_select = model_select model_select.currentIndexChanged.connect( self.onChangeSend) # <<< On change function font = model_select.font() font.setPointSize(self.font_size) model_select.setFont(font) hbox_model_select.addWidget(text_model_select) hbox_model_select.addWidget(model_select) layout.addLayout(hbox_model_select) # Sliders percentage, self.percentage_slider = self.add_slider( "Relative position in audio:", style, value=self.DEFAULT_POSITION, maximum=1000) length, self.length_slider = self.add_slider("Length:", style, value=self.DEFAULT_LENGTH, maximum=124, minimum=4) change_speed, self.change_speed_slider = self.add_slider( "Transition speed:", style, value=self.DEFAULT_CHANGESPEED, maximum=200) volume, self.volume_slider = self.add_slider("Volume:", style, value=self.DEFAULT_VOLUME, maximum=300) weights_multiplier, self.weights_multiplier = self.add_double_slider( "Weights Multiplier:", style, minimum=-1, value=1, maximum=2) layout.addLayout(percentage) layout.addLayout(length) layout.addLayout(change_speed) layout.addLayout(volume) layout.addLayout(weights_multiplier) # Record button hbox_record = QHBoxLayout() recButton = QPushButton("Save!") recButton.setStyleSheet(style) hbox_record.addWidget(recButton) recButton.setCheckable(True) file_textbox = QLineEdit() file_textbox.setText("tmp_recording1") hbox_record.addWidget(file_textbox) self.file_textbox = file_textbox self.recButton = recButton self.recButton_state = False recButton.clicked.connect(self.recording_toggle) layout.addLayout(hbox_record) self.setLayout(layout)
def __init__(self, settings, manual_loading=False): settings.print_settings() self.settings = settings self.preloaded_impulses = None self.first_iteration = True self.keep_only_newly_generated = True self.continue_impulse_from_previous_batch = True # SPECIAL MODE - RESTART SEED EVERY "requested_length"-worth of generated music # ... when self.continue_impulse_from_previous_batch is False #self.continue_impulse_from_previous_batch = False self.previous_audio_overlap = None self.change_impulses_smoothly = True #self.change_impulses_smoothly = False self._is_changing_impulses = False self._change_step = 0 self._change_steps = 120 self.model_i = 0 self.song_i = 0 self.interactive_i = 0 self.weights_multiplier = 1.0 self.audio_handler = audio_handler.AudioHandler( griffin_iterations=settings.griffin_iterations, sample_rate=settings.sample_rate, fft_size=settings.fft_size, window_size=settings.window_size, hop_size=settings.hop_size, sequence_length=settings.sequence_length) self.model_handler = model_handler_lstm.ModelHandlerLSTM( settings.lstm_layers, settings.lstm_units, self.settings) self.graph = tf.Graph() with self.graph.as_default(): self.model_handler.create_model() # recreate? # Create a model #self.model_handler.create_model() print("Created model:", self.model_handler.model) if not manual_loading: self.songs_models = cooked_files_handler.CookedFilesHandler( settings) self.songs_models.prepare_songs_models_paths() # Load model weights & song impulses t_load_model = timer() self.load_weights(model_i=self.model_i) t_load_model = timer() - t_load_model t_load_song = timer() if self.preloaded_impulses is None: print("Also have to load the song") # this happens in Regular load mode (aka with older models) self.load_impulses( song_i=self.song_i ) # no need we have the first one with the weights already self.change_impulse(interactive_i=self.interactive_i) t_load_song = timer() - t_load_song #print("Model loaded in", t_load_model, ", song loaded in", t_load_song, "(sec).") print("Model and song loaded in", t_load_model, "(sec).") # Time on potato pc: Model loaded in 1.007, song loaded in 12.365 (sec). self.VERBOSE = 1 # Additional HAXs self.extended_functionality_function = None
def __init__(self, parent=None): super(GUI_OSC, self).__init__(parent) self.setWindowTitle("Interactive Music Generation") self.font_size = 14 address = "127.0.0.1" port = 8008 self.osc = OSCClient(address, port, encoding='utf8') self.text = "" import settings import cooked_files_handler self.settings = settings.Settings() self.songs_models = cooked_files_handler.CookedFilesHandler( self.settings) self.songs_models.prepare_songs_models_paths() layout = QVBoxLayout() style = "QWidget {font-size: " + str(self.font_size) + "pt;}" hbox_model_select = QHBoxLayout() text_model_select = QLabel() text_model_select.setText("Model selection:") text_model_select.setStyleSheet(style) model_select = QComboBox() for model_path in self.songs_models.model_paths: just_model = model_path.split("/")[-1] just_model = just_model[0:min(len(just_model), 30)] model_select.addItem(just_model) self.model_select = model_select model_select.currentIndexChanged.connect( self.onChangeSend) # <<< On change function font = model_select.font() font.setPointSize(self.font_size) model_select.setFont(font) hbox_model_select.addWidget(text_model_select) hbox_model_select.addWidget(model_select) layout.addLayout(hbox_model_select) # Sliders percentage, self.percentage_slider = self.add_slider( "Relative position in audio:", style, value=200, maximum=1000) length, self.length_slider = self.add_slider("Length:", style, value=64, maximum=124, minimum=4) change_speed, self.change_speed_slider = self.add_slider( "Transition speed:", style, value=80, maximum=200) volume, self.volume_slider = self.add_slider("Volume:", style, value=100, maximum=300) weights_multiplier, self.weights_multiplier = self.add_double_slider( "Weights Multiplier:", style, minimum=-1, value=1, maximum=2) layout.addLayout(percentage) layout.addLayout(length) layout.addLayout(change_speed) layout.addLayout(volume) layout.addLayout(weights_multiplier) # Record button hbox_record = QHBoxLayout() recButton = QPushButton("Save!") recButton.setStyleSheet(style) hbox_record.addWidget(recButton) recButton.setCheckable(True) file_textbox = QLineEdit() file_textbox.setText("tmp_recording1") hbox_record.addWidget(file_textbox) self.file_textbox = file_textbox self.recButton = recButton self.recButton_state = False recButton.clicked.connect(self.recording_toggle) layout.addLayout(hbox_record) self.setLayout(layout)