diff options
author | Tim E. Real <termtech@rogers.com> | 2012-12-12 08:28:29 +0000 |
---|---|---|
committer | Tim E. Real <termtech@rogers.com> | 2012-12-12 08:28:29 +0000 |
commit | 079a13764229873cc395c808a0333674b790edbf (patch) | |
tree | 5f3cebb50d315c0b0cddd305df44b0052e7ccd98 /muse2 | |
parent | bfa869ee23aa5da09f18d930766f1d6321854c1b (diff) |
Add stdint.h to vestige header.
Some WIP trying to fix odd patch name bug (shows @u@ etc).
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/muse/instruments/minstrument.cpp | 4 | ||||
-rw-r--r-- | muse2/muse/instruments/minstrument.h | 2 | ||||
-rw-r--r-- | muse2/muse/synth.h | 9 | ||||
-rw-r--r-- | muse2/muse/vst_native.cpp | 16 | ||||
-rw-r--r-- | muse2/muse/widgets/mtrackinfo.cpp | 60 | ||||
-rw-r--r-- | muse2/muse/widgets/mtrackinfo.h | 1 | ||||
-rw-r--r-- | muse2/vestige/aeffectx.h | 2 |
7 files changed, 79 insertions, 15 deletions
diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp index e2477e60..b7a2c7bf 100644 --- a/muse2/muse/instruments/minstrument.cpp +++ b/muse2/muse/instruments/minstrument.cpp @@ -1093,7 +1093,7 @@ void MidiInstrument::populatePatchPopup(MusEGui::PopupMenu* menu, int /*chan*/, // getPatchName //--------------------------------------------------------- -QString MidiInstrument::getPatchName(int /*channel*/, int prog, bool drum) +const char* MidiInstrument::getPatchName(int /*channel*/, int prog, bool drum) const { int pr = prog & 0xff; if(prog == CTRL_VAL_UNKNOWN || pr == 0xff) @@ -1115,7 +1115,7 @@ QString MidiInstrument::getPatchName(int /*channel*/, int prog, bool drum) && (hbank == mp->hbank || !hb || mp->hbank == -1) && (lbank == mp->lbank || !lb || mp->lbank == -1)) - return mp->name; + return mp->name.toLatin1().constData(); } } return "<unknown>"; diff --git a/muse2/muse/instruments/minstrument.h b/muse2/muse/instruments/minstrument.h index 7ff6f7d8..665c2437 100644 --- a/muse2/muse/instruments/minstrument.h +++ b/muse2/muse/instruments/minstrument.h @@ -238,7 +238,7 @@ class MidiInstrument { virtual void writeToGui(const MidiPlayEvent&) {} virtual void reset(int); - virtual QString getPatchName(int,int,bool); + virtual const char* getPatchName(int,int,bool) const; virtual void populatePatchPopup(MusEGui::PopupMenu*, int, bool); void read(Xml&); void write(int level, Xml&); diff --git a/muse2/muse/synth.h b/muse2/muse/synth.h index c41d5535..62c461c4 100644 --- a/muse2/muse/synth.h +++ b/muse2/muse/synth.h @@ -270,8 +270,13 @@ class SynthI : public AudioTrack, public MidiDevice, Synth* synth() const { return synthesizer; } virtual bool isSynti() const { return true; } - virtual QString getPatchName(int ch, int prog, bool dr) { - return _sif->getPatchName(ch, prog, dr); + virtual const char* getPatchName(int ch, int prog, bool dr) const { + // REMOVE Tim. + const char* s = _sif->getPatchName(ch, prog, dr); + //fprintf(stderr, "SynthI::getPatchName patch name:%s\n", s); // REMOVE Tim. + return s; + + ///return _sif->getPatchName(ch, prog, dr); } virtual void populatePatchPopup(MusEGui::PopupMenu* m, int i, bool d) { diff --git a/muse2/muse/vst_native.cpp b/muse2/muse/vst_native.cpp index 419c996f..6de5f8f4 100644 --- a/muse2/muse/vst_native.cpp +++ b/muse2/muse/vst_native.cpp @@ -956,7 +956,9 @@ VstIntPtr VstNativeSynthIF::hostCallback(VstInt32 opcode, VstInt32 index, VstInt // Can't use song pos - it is only updated every (slow) GUI heartbeat ! //Pos p(MusEGlobal::extSyncFlag.value() ? MusEGlobal::song->cpos() : pos->frame, MusEGlobal::extSyncFlag.value() ? true : false); - // TODO + + //unsigned int tick_pos = MusEGlobal::audio->tickPos(); + int p_bar, p_beat, p_tick; p.mbt(&p_bar, &p_beat, &p_tick); @@ -981,7 +983,6 @@ VstIntPtr VstNativeSynthIF::hostCallback(VstInt32 opcode, VstInt32 index, VstInt _timeInfo.timeSigDenominator = n; #endif - // TODO ////pos->ticks_per_beat = 24; //pos->ticks_per_beat = MusEGlobal::config.division; @@ -1413,6 +1414,8 @@ void VstNativeSynthIF::queryPrograms() } //#endif + //fprintf(stderr, " VstNativeSynthIF::queryPrograms(): patch name:%s\n", buf); // REMOVE Tim. + int bankH = (prog >> 14) & 0x7f; int bankL = (prog >> 7) & 0x7f; int patch = prog & 0x7f; @@ -1527,13 +1530,18 @@ const char* VstNativeSynthIF::getPatchName(int /*chan*/, int prog, bool /*drum*/ if (hbank == 0xff) hbank = 0; unsigned long p = (hbank << 16) | (lbank << 8) | program; - int vp = (hbank << 14) | (lbank << 7) | program; - if((int)vp < _plugin->numPrograms) + unsigned long vp = (hbank << 14) | (lbank << 7) | program; + //if((int)vp < _plugin->numPrograms) + if(vp < programs.size()) { for(std::vector<VST_Program>::const_iterator i = programs.begin(); i != programs.end(); ++i) { + //fprintf(stderr, " VstNativeSynthIF::patch name:%s\n", i->name.toLatin1().constData()); // REMOVE Tim. if(i->program == p) + { + //fprintf(stderr, " found patch name:%s\n", i->name.toLatin1().constData()); // REMOVE Tim. return i->name.toLatin1().constData(); + } } } return "?"; diff --git a/muse2/muse/widgets/mtrackinfo.cpp b/muse2/muse/widgets/mtrackinfo.cpp index 80b9a76a..203a81e7 100644 --- a/muse2/muse/widgets/mtrackinfo.cpp +++ b/muse2/muse/widgets/mtrackinfo.cpp @@ -90,6 +90,7 @@ MidiTrackInfo::MidiTrackInfo(QWidget* parent, MusECore::Track* sel_track) : QWid setupUi(this); _midiDetect = false; heartBeatCounter = 0; + _blockHeartbeatCount = 0; selected = sel_track; @@ -278,7 +279,13 @@ MidiTrackInfo::MidiTrackInfo(QWidget* parent, MusECore::Track* sel_track) : QWid void MidiTrackInfo::heartBeat() { ///if(!showTrackinfoFlag || !selected) - if(!isVisible() || !isEnabled() || !selected) + if(_blockHeartbeatCount < 0) // error + { + fprintf(stderr, "ERROR: MidiTrackInfo::heartBeat: _blockHeartbeatCount is < 0, resetting to 0\n"); + _blockHeartbeatCount = 0; + } + + if(_blockHeartbeatCount > 0 || !isVisible() || !isEnabled() || !selected) return; switch(selected->type()) { @@ -407,14 +414,17 @@ void MidiTrackInfo::heartBeat() else { MusECore::MidiInstrument* instr = mp->instrument(); - QString name = instr->getPatchName(outChannel, nprogram, track->isDrumTrack()); + const QString name = instr->getPatchName(outChannel, nprogram, track->isDrumTrack()); + //const char* name = instr->getPatchName(outChannel, nprogram, track->isDrumTrack()); if(name.isEmpty()) + //if(name == NULL) { const QString n("???"); if(iPatch->text() != n) iPatch->setText(n); } else if(iPatch->text() != name) + //else if(strcmp(iPatch->text().constData(), QChar name)) iPatch->setText(name); } } @@ -448,8 +458,12 @@ void MidiTrackInfo::heartBeat() //else //{ MusECore::MidiInstrument* instr = mp->instrument(); - QString name = instr->getPatchName(outChannel, program, track->isDrumTrack()); + //const QString name = instr->getPatchName(outChannel, program, track->isDrumTrack()); + const char* chr_name = instr->getPatchName(outChannel, program, track->isDrumTrack()); + const QString name(chr_name); + //fprintf(stderr, "patch name qstring:%s charstr:%s\n", name.toLatin1().constData(), chr_name); // REMOVE Tim. if(iPatch->text() != name) + //if(!strcmp(iPatch->text().toLatin1().constData(), name)) iPatch->setText(name); int hb = ((program >> 16) & 0xff) + 1; @@ -674,6 +688,7 @@ void MidiTrackInfo::iOutputChannelChanged(int channel) return; MusECore::MidiTrack* track = (MusECore::MidiTrack*)selected; if (channel != track->outChannel()) { + ++_blockHeartbeatCount; // Changed by T356. //track->setOutChannel(channel); MusEGlobal::audio->msgIdle(true); @@ -687,6 +702,7 @@ void MidiTrackInfo::iOutputChannelChanged(int channel) MusEGlobal::audio->msgUpdateSoloStates(); // p4.0.14 //MusEGlobal::song->update(SC_MIDI_TRACK_PROP | SC_ROUTE); // MusEGlobal::song->update(SC_MIDI_TRACK_PROP); // + --_blockHeartbeatCount; } } @@ -704,6 +720,7 @@ void MidiTrackInfo::iOutputPortChanged(int index) MusECore::MidiTrack* track = (MusECore::MidiTrack*)selected; if (port_num == track->outPort()) return; + ++_blockHeartbeatCount; // Changed by T356. //track->setOutPort(port_num); MusEGlobal::audio->msgIdle(true); @@ -715,6 +732,7 @@ void MidiTrackInfo::iOutputPortChanged(int index) MusEGlobal::audio->msgUpdateSoloStates(); // p4.0.14 //MusEGlobal::song->update(SC_MIDI_TRACK_PROP | SC_ROUTE); // MusEGlobal::song->update(SC_MIDI_TRACK_PROP); // + --_blockHeartbeatCount; } //--------------------------------------------------------- @@ -785,11 +803,14 @@ void MidiTrackInfo::iProgHBankChanged() if(prog == 0xff && hbank == 0xff && lbank == 0xff) { program = MusECore::CTRL_VAL_UNKNOWN; + ++_blockHeartbeatCount; if(mp->hwCtrlState(channel, MusECore::CTRL_PROGRAM) != MusECore::CTRL_VAL_UNKNOWN) MusEGlobal::audio->msgSetHwCtrlState(mp, channel, MusECore::CTRL_PROGRAM, MusECore::CTRL_VAL_UNKNOWN); + --_blockHeartbeatCount; return; } + ++_blockHeartbeatCount; int np = mp->hwCtrlState(channel, MusECore::CTRL_PROGRAM); if(np == MusECore::CTRL_VAL_UNKNOWN) { @@ -829,6 +850,8 @@ void MidiTrackInfo::iProgHBankChanged() MusECore::MidiInstrument* instr = mp->instrument(); iPatch->setText(instr->getPatchName(channel, program, track->isDrumTrack())); // updateTrackInfo(); + + --_blockHeartbeatCount; } //--------------------------------------------------------- @@ -863,11 +886,14 @@ void MidiTrackInfo::iProgLBankChanged() if(prog == 0xff && hbank == 0xff && lbank == 0xff) { program = MusECore::CTRL_VAL_UNKNOWN; + ++_blockHeartbeatCount; if(mp->hwCtrlState(channel, MusECore::CTRL_PROGRAM) != MusECore::CTRL_VAL_UNKNOWN) MusEGlobal::audio->msgSetHwCtrlState(mp, channel, MusECore::CTRL_PROGRAM, MusECore::CTRL_VAL_UNKNOWN); + --_blockHeartbeatCount; return; } + ++_blockHeartbeatCount; int np = mp->hwCtrlState(channel, MusECore::CTRL_PROGRAM); if(np == MusECore::CTRL_VAL_UNKNOWN) { @@ -907,6 +933,8 @@ void MidiTrackInfo::iProgLBankChanged() MusECore::MidiInstrument* instr = mp->instrument(); iPatch->setText(instr->getPatchName(channel, program, track->isDrumTrack())); // updateTrackInfo(); + + --_blockHeartbeatCount; } //--------------------------------------------------------- @@ -940,6 +968,7 @@ void MidiTrackInfo::iProgramChanged() MusECore::MidiPort *mp = &MusEGlobal::midiPorts[port]; if(prog == 0xff) { + ++_blockHeartbeatCount; program = MusECore::CTRL_VAL_UNKNOWN; iHBank->blockSignals(true); iLBank->blockSignals(true); @@ -950,10 +979,12 @@ void MidiTrackInfo::iProgramChanged() if(mp->hwCtrlState(channel, MusECore::CTRL_PROGRAM) != MusECore::CTRL_VAL_UNKNOWN) MusEGlobal::audio->msgSetHwCtrlState(mp, channel, MusECore::CTRL_PROGRAM, MusECore::CTRL_VAL_UNKNOWN); - return; + --_blockHeartbeatCount; + return; } else { + ++_blockHeartbeatCount; int np = mp->hwCtrlState(channel, MusECore::CTRL_PROGRAM); if(np == MusECore::CTRL_VAL_UNKNOWN) { @@ -984,6 +1015,8 @@ void MidiTrackInfo::iProgramChanged() MusECore::MidiInstrument* instr = mp->instrument(); iPatch->setText(instr->getPatchName(channel, program, track->isDrumTrack())); + + --_blockHeartbeatCount; } // updateTrackInfo(); @@ -1129,9 +1162,11 @@ void MidiTrackInfo::instrPopupActivated(QAction* act) MusECore::MidiTrack* track = (MusECore::MidiTrack*)selected; int channel = track->outChannel(); int port = track->outPort(); + ++_blockHeartbeatCount; MusECore::MidiPlayEvent ev(0, port, channel, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, rv); MusEGlobal::audio->msgPlayMidiEvent(&ev); updateTrackInfo(-1); + --_blockHeartbeatCount; } } } @@ -1167,9 +1202,11 @@ void MidiTrackInfo::instrPopup() int rv = act->data().toInt(); if(rv != -1) { + ++_blockHeartbeatCount; MusECore::MidiPlayEvent ev(0, port, channel, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, rv); MusEGlobal::audio->msgPlayMidiEvent(&ev); updateTrackInfo(-1); + --_blockHeartbeatCount; } } @@ -1227,10 +1264,12 @@ void MidiTrackInfo::iProgHBankDoubleCLicked() // kiv = mctrl->maxVal(); //kiv += mctrl->bias(); //} - + + ++_blockHeartbeatCount; //MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, num, kiv); MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, kiv); MusEGlobal::audio->msgPlayMidiEvent(&ev); + --_blockHeartbeatCount; } else { @@ -1241,8 +1280,10 @@ void MidiTrackInfo::iProgHBankDoubleCLicked() // else // lastv |= 0xff0000; + ++_blockHeartbeatCount; MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, lastv); MusEGlobal::audio->msgPlayMidiEvent(&ev); + --_blockHeartbeatCount; } } else @@ -1263,7 +1304,11 @@ void MidiTrackInfo::iProgHBankDoubleCLicked() // curv |= 0xff0000; if(mp->hwCtrlState(chan, MusECore::CTRL_PROGRAM) != MusECore::CTRL_VAL_UNKNOWN) + { + ++_blockHeartbeatCount; MusEGlobal::audio->msgSetHwCtrlState(mp, chan, MusECore::CTRL_PROGRAM, MusECore::CTRL_VAL_UNKNOWN); + --_blockHeartbeatCount; + } // MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, curv); // MusEGlobal::audio->msgPlayMidiEvent(&ev); } @@ -1557,6 +1602,8 @@ void MidiTrackInfo::updateTrackInfo(MusECore::SongChangedFlags_t flags) if(!selected) return; MusECore::MidiTrack* track = (MusECore::MidiTrack*)selected; + + ++_blockHeartbeatCount; setLabelText(); setLabelFont(); @@ -1651,7 +1698,7 @@ void MidiTrackInfo::updateTrackInfo(MusECore::SongChangedFlags_t flags) program = MusECore::CTRL_VAL_UNKNOWN; nprogram = mp->lastValidHWCtrlState(outChannel, MusECore::CTRL_PROGRAM); - if(nprogram == MusECore::CTRL_VAL_UNKNOWN) + if(nprogram == MusECore::CTRL_VAL_UNKNOWN) //iPatch->setText(QString("<unknown>")); iPatch->setText(tr("<unknown>")); else @@ -1737,6 +1784,7 @@ void MidiTrackInfo::updateTrackInfo(MusECore::SongChangedFlags_t flags) iPan->blockSignals(false); //} + --_blockHeartbeatCount; } //--------------------------------------------------------- diff --git a/muse2/muse/widgets/mtrackinfo.h b/muse2/muse/widgets/mtrackinfo.h index d6b3f32a..bb14423d 100644 --- a/muse2/muse/widgets/mtrackinfo.h +++ b/muse2/muse/widgets/mtrackinfo.h @@ -43,6 +43,7 @@ class MidiTrackInfo : public QWidget, public Ui::MidiTrackInfoBase bool _midiDetect; int program, pan, volume; int heartBeatCounter; + int _blockHeartbeatCount; protected: virtual void resizeEvent(QResizeEvent*); diff --git a/muse2/vestige/aeffectx.h b/muse2/vestige/aeffectx.h index fe0adef3..11731c6c 100644 --- a/muse2/vestige/aeffectx.h +++ b/muse2/vestige/aeffectx.h @@ -26,6 +26,8 @@ #ifndef _AEFFECTX_H #define _AEFFECTX_H +#include <stdint.h> + #define CCONST(a, b, c, d)( ( ( (int) a ) << 24 ) | \ ( ( (int) b ) << 16 ) | \ ( ( (int) c ) << 8 ) | \ |