예제 #1
0
 def __init__(self, csv_col_name, csv_col_idx, midi, config, channel):
     # Remember the index of the column this object is assigned to so that
     # its value can be accessed from a row taken from the csv file.
     self._csv_col_idx = csv_col_idx
     # get the name of the instrument assigned to this csv column
     instrument_name = config['columns'][csv_col_name]
     # look up the instrument in the database
     instrument = InstrumentDb.get_instrument(instrument_name)
     # get the values used in transforming the raw csv file value into a
     # midi note value
     self._instrument_multiplier = float(instrument.max_pitch -
                                         instrument.min_pitch)
     self._instrument_min = instrument.min_pitch
     # set the midi program number, which corresponds to the instrument
     self._program = instrument.program
     # _max_value is the maximum value of the csv column this instance is
     # assigned to. It will be initialized by iterating through the entire
     # csv file and calling test_for_max.
     self._max_value = 0.0
     self._midi = midi
     self._channel = channel
     self._note_time = 0
     # set the instrument for the channel owned by this instance
     track = 0
     self._midi.addProgramChange(track, self._channel,self._note_time,
                                 self._program)
예제 #2
0
 def _update_instrument_combo(self, instrument_name=None):
     # Empty out the instrument combo, then fill it with the instruments in
     # the current family.
     old_block = self.instrument_combo.blockSignals(True)
     self.instrument_combo.clear()
     family_index = self.family_combo.currentIndex()
     instrument_names = InstrumentDb.get_instrument_names_by_family_index(
         family_index)
     if instrument_names:
         self.instrument_combo.addItems(instrument_names)
         if instrument_name is not None:
             self.instrument_combo.setCurrentIndex(instrument_names.index(
                 instrument_name))
     self.instrument_combo.blockSignals(old_block)
예제 #3
0
 def table_selection_changed(self):
     """Make the comboboxes match the values in the currently selected
     item."""
     # Turn off signals in the comboboxes while we change them
     # programmatically.
     self._block_combo_signals(True)
     # Get the instrument name associated with the newly selected row.
     selected_table_items = self.table.selectedItems()
     selected_table_instrument = selected_table_items[1].text()
     # Set the family combobox to have the family that contains the
     # instrument which the selected table row is currently displaying.
     family_index = InstrumentDb.get_family_index(
         selected_table_instrument)
     self.family_combo.setCurrentIndex(family_index)
     # Make the instrument combobox display the instruments for the current
     # family, and select the same instrument that the table is displaying.
     self._update_instrument_combo(selected_table_instrument)
     # Turn signals back on so when user changes combobox we handle it
     self._block_combo_signals(False)
예제 #4
0
 def _init_family_combo(self):
     """Initialize the instrument family combo box."""
     self.family_combo.addItems(InstrumentDb.get_families())
     self.family_combo.currentIndexChanged.connect(self.family_combo_changed)