Ejemplo n.º 1
0
ArticulationProperties::ArticulationProperties(Articulation* na, QWidget* parent)
   : QDialog(parent)
      {
      setupUi(this);
      setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);

      articulation = na;

      ChordRest* cr = articulation->chordRest();
      if (cr) {
            Segment* segment       = cr->segment();
            Part* part             = articulation->staff()->part();
            Instrument* instrument = part->instr(segment->tick());

//      const QList<NamedEventList>& midiActions() const;
//      const QList<MidiArticulation>& articulation() const;
//      const QList<Channel>& channel() const;

            foreach(const Channel& a, instrument->channel()) {
                  if (a.name.isEmpty() || a.name == "normal")
                        channelList->addItem(tr("normal"));
                  else
                        channelList->addItem(a.name);
                  }
            foreach(const NamedEventList& el, instrument->midiActions()) {
                  midiActionList->addItem(el.name);
                  }
            }

#if 0
      foreach(const NamedEventList& e, instrument->midiActions)
            midiActionList->addItem(e.name);
      articulationChange->setChecked(!articulation->articulationName().isEmpty());
      midiAction->setChecked(!articulation->midiActionName().isEmpty());

      if (!articulation->articulationName().isEmpty()) {
            QList<QListWidgetItem*> wl = articulationList
               ->findItems(st->articulationName(), Qt::MatchExactly);
            if (!wl.isEmpty())
                  articulationList->setCurrentRow(articulationList->row(wl[0]));
            }
      if (!articulation->midiActionName().isEmpty()) {
            QList<QListWidgetItem*> wl = midiActionList
               ->findItems(st->midiActionName(), Qt::MatchExactly);
            if (!wl.isEmpty())
                  midiActionList->setCurrentRow(midiActionList->row(wl[0]));
            }
#endif

      direction->setCurrentIndex(int(articulation->direction()));
      anchor->setCurrentIndex(int(articulation->anchor()));

      connect(this, SIGNAL(accepted()), SLOT(saveValues()));
      }
Ejemplo n.º 2
0
MixerTrackPart::MixerTrackPart(QWidget *parent, MixerTrackItemPtr mti, bool expanded) :
      QWidget(parent), _mti(mti), _selected(false), _group(0)
      {
      setupUi(this);

      int numChannels = 0;
      Part* part = _mti->part();
      const InstrumentList* il = part->instruments();
      for (auto it = il->begin(); it != il->end(); ++it) {
            Instrument* instr = it->second;
            numChannels += instr->channel().size();
            }

      expandBn->setEnabled(numChannels > 1);
      expandBn->setChecked(expanded);

      connect(expandBn, SIGNAL(toggled(bool)), SLOT(expandToggled(bool)));

      connect(soloBn, SIGNAL(toggled(bool)), SLOT(updateSolo(bool)));
      connect(muteBn, SIGNAL(toggled(bool)), SLOT(updateMute(bool)));

      updateNameLabel();

      //set up rest

      Channel* chan = _mti->focusedChan();

      soloBn->setChecked(chan->solo());
      muteBn->setChecked(chan->mute());

      chan->addListener(this);
      volumeSlider->setValue(chan->volume());
      volumeSlider->setToolTip(tr("Volume: %1").arg(QString::number(chan->volume())));
      volumeSlider->setMaxValue(127);
      volumeSlider->setMinValue(0);
      volumeSlider->setNumMajorTicks(10);
      volumeSlider->setNumMinorTicks(4);

      QIcon iconSliderHead;
      iconSliderHead.addFile(QStringLiteral(":/data/icons/mixer-slider-handle-vertical.svg"), QSize(), QIcon::Normal, QIcon::Off);
      volumeSlider->setSliderHeadIcon(iconSliderHead);

      panSlider->setValue(chan->pan());
      panSlider->setToolTip(tr("Pan: %1").arg(QString::number(chan->pan())));
      panSlider->setMaxValue(127);
      panSlider->setMinValue(0);

      connect(volumeSlider, SIGNAL(valueChanged(double)),      SLOT(volumeChanged(double)));
      connect(panSlider,    SIGNAL(valueChanged(double, int)), SLOT(panChanged(double)));

      connect(volumeSlider, SIGNAL(sliderPressed()),    SLOT(controlSelected()));
      connect(panSlider,    SIGNAL(sliderPressed(int)), SLOT(controlSelected()));
      }
Ejemplo n.º 3
0
void Seq::playEvent(const SeqEvent& event)
      {
      int type = event.type();
      if (type == ME_NOTEON) {
            bool mute;
            const Note* note = event.note();

            if (note) {
                  Instrument* instr = note->staff()->part()->instr();
                  const Channel& a = instr->channel(note->subchannel());
                  mute = a.mute || a.soloMute;
                  }
            else
                  mute = false;

            if (!mute)
                  synti->play(event);
            }
      else if (type == ME_CONTROLLER)
            synti->play(event);
      }
Ejemplo n.º 4
0
void SMFTrack::update()
{
  Instrument *inst = smf_.instrument();
  if (inst == NULL) {
    return;
  }
  if (!is_playing() || is_paused()) {
    return;
  }
  if (wait_time_ > 0) {
    --wait_time_;
    if (wait_time_ > 0) {
      return;
    }
  }
  if (data_end_ <= data_cur_) {
    return;
  }
  do {
    data_type data = *data_cur_++;
    Channel &ch = inst->channel(data & 0x0f);
#ifdef ENABLE_RUNNING_STATUS
  retry:
#endif
    switch (static_cast<unsigned char>(data)) {
#ifdef ENABLE_RUNNING_STATUS
    case 0x00 ... 0x7f:		// Running Status
      data = prev_status_byte;
      goto retry;
      //break;
#endif
    case 0x80 ... 0x8f:		// 8n kk vv   Note Off
      {
	data_type kk = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.note_off(kk, vv);
      }
      break;
    case 0x90 ... 0x9f:		// 9n kk vv   Note On
      {
	data_type kk = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.note_on(kk, vv);
      }
      break;
    case 0xa0 ... 0xaf:		// An kk vv   Polyphonic Pressure
      {
	data_type kk = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.polyphonic_pressure(kk, vv);
      }
      break;
    case 0xb0 ... 0xbf:		// Bn cc vv   Control Change
      {
	data_type cc = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.control_change(cc, vv);
      }
      break;
    case 0xc0 ... 0xcf:		// Cn pp      Program Change
      {
	data_type pp = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.program_change(pp);
      }
      break;
    case 0xd0 ... 0xdf:		// Dn vv      Channel Pressure
      {
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.channel_pressure(vv);
      }
      break;
    case 0xe0 ... 0xef:		// En ll mm   Pitch Bend
      {
	data_type ll = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type mm = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.pitch_bend_change(mm * 128 + ll - 8192);
      }
      break;
    case 0xf0:	       		// F0 ... F7  SysEx
      {
	VariableLengthValue delta_time;
	VariableLengthValue::len_type vlv_len = delta_time.set_data(data_cur_, 0);
	data_cur_ += vlv_len + delta_time.value();
	assert(data_cur_ <= data_end_);
      }
    case 0xf7:			// F7 ...     SysEx
      {
	VariableLengthValue delta_time;
	VariableLengthValue::len_type vlv_len = delta_time.set_data(data_cur_, 0);
	data_cur_ += vlv_len + delta_time.value();
	assert(data_cur_ <= data_end_);
      }
      break;
    case 0xff:
      {
	data_type type = *data_cur_++;
	assert(data_cur_ <= data_end_);
	VariableLengthValue data_len;
	VariableLengthValue::len_type vlv_len = data_len.set_data(data_cur_, 0);
	data_cur_ += vlv_len;
	assert(data_cur_ <= data_end_);
	switch (type) {
	case 0x01: // FF 01 len text		Text Event
	case 0x02: // FF 02 len text		Copyright Notice
	case 0x03: // FF 03 len text		Sequence/Track Name
	case 0x04: // FF 04 len text		Instrument Name
	case 0x05: // FF 05 len text		Lyric
	case 0x06: // FF 06 len text		Marker
	case 0x07: // FF 07 len text		Cue Point
	case 0x09: // FF 09 len text		Device Name
	case 0x20: // FF 20 01 cc		MIDI Channel Prefix
	case 0x54: // FF 54 05 hr mn se fr ff	SMPTE Offset
	case 0x58: // FF 58 04 nn dd cc bb	Time Signature
	case 0x59: // FF 59 02 sf mi		Key Signature
	case 0x7f: // FF 7F len data		Sequencer Specific Meta-Event
	  // not implemented
	  data_cur_ += data_len.value();
	  assert(data_cur_ <= data_end_);
	  break;
	case 0x2f: // FF 2F 00			End of Track
#ifdef SMF_TRACK_DEBUG
	  if (data_len.value() > 0) {
	    WARN("End of Track event is too long: %u > 0", data_len.value());
	  }
#endif
	  data_cur_ += data_len.value();
	  stop();
	  break;
	case 0x51: // FF 51 03 tttttt		Set Tempo(in microseconds per MIDI quarter-note)
	  smf_.set_tempo(reinterpret_cast<const uint8_t *>(data_cur_));
	  data_cur_ += data_len.value();
	  assert(data_cur_ <= data_end_);
	  break;
	default:
	  // unsupported meta-events
#ifdef SMF_TRACK_DEBUG
	  INFO("Unimplemented meta events: type=%02x, len=%u", static_cast<uint8_t>(type), data_len.value());
#endif
	  data_cur_ += data_len.value();
	  assert(data_cur_ <= data_end_);
	  break;
	}
      }
      break;
    default:
      // unsupported events
#ifdef SMF_TRACK_DEBUG
      INFO("Unimplemented events: %02x", static_cast<uint8_t>(data));
#endif
      break;
    }
#ifdef ENABLE_RUNNING_STATUS
    prev_status_byte = data;
#endif
    if (!is_playing()) {
      break;
    }
    update_wait_time();
  } while (wait_time_ == 0);
}
Ejemplo n.º 5
0
void GuitarPro5::readTracks()
      {
      for (int i = 0; i < staves; ++i) {
            int tuning[GP_MAX_STRING_NUMBER];
            Staff* staff = score->staff(i);
            Part* part = staff->part();

            uchar c = readUChar();   // simulations bitmask
            if (c & 0x2) {                // 12 stringed guitar
                  }
            if (c & 0x4) {                // banjo track
                  }
            if (i == 0 || version == 500)
                  skip(1);
            QString name = readPascalString(40);

            int strings  = readInt();
            if (strings <= 0 || strings > GP_MAX_STRING_NUMBER)
                  throw GuitarProError::GP_BAD_NUMBER_OF_STRINGS ;
            for (int j = 0; j < strings; ++j) {
                  tuning[j] = readInt();
                  }
            for (int j = strings; j < GP_MAX_STRING_NUMBER; ++j)
                  readInt();
            /*int midiPort     =*/ readInt();   // -1
            int midiChannel  = readInt() - 1;
            /*int midiChannel2 =*/ readInt();   // -1

            int frets        = readInt();
            int capo         = readInt();
            /*int color        =*/ readInt();

            skip(version > 500 ? 49 : 44);
            if (version > 500) {
                  //  british stack clean / amp tone
                  readDelphiString();
                  readDelphiString();
                  }

            int tuning2[strings];
            for (int k = 0; k < strings; ++k)
                  tuning2[strings-k-1] = tuning[k];
            StringData stringData(frets, strings, tuning2);
            Instrument* instr = part->instr();
            instr->setStringData(stringData);
            part->setPartName(name);
            part->setLongName(name);
            instr->setTranspose(Interval(capo));

            //
            // determine clef
            //
            int patch = channelDefaults[midiChannel].patch;
            ClefType clefId = ClefType::G;
            if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
                  clefId = ClefType::PERC;
                  // instr->setUseDrumset(DrumsetKind::GUITAR_PRO);
                  instr->setDrumset(gpDrumset);
                  staff->setStaffType(StaffType::preset(StaffTypes::PERC_DEFAULT));
                  }
            else if (patch >= 24 && patch < 32)
                  clefId = ClefType::G3;
            else if (patch >= 32 && patch < 40)
                  clefId = ClefType::F8;
            Measure* measure = score->firstMeasure();
            Clef* clef = new Clef(score);
            clef->setClefType(clefId);
            clef->setTrack(i * VOICES);
            Segment* segment = measure->getSegment(Segment::Type::Clef, 0);
            segment->add(clef);

            Channel& ch = instr->channel(0);
            if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
                  ch.program = 0;
                  ch.bank    = 128;
                  }
            else {
                  ch.program = patch;
                  ch.bank    = 0;
                  }
            ch.volume  = channelDefaults[midiChannel].volume;
            ch.pan     = channelDefaults[midiChannel].pan;
            ch.chorus  = channelDefaults[midiChannel].chorus;
            ch.reverb  = channelDefaults[midiChannel].reverb;
            //qDebug("default2: %d", channelDefaults[i].reverb);
            // missing: phase, tremolo
            ch.updateInitList();
            }
      skip(version == 500 ? 2 : 1);
      }