Skip to content

Commit

Permalink
muxseq+muxseqsig start/stop signalling
Browse files Browse the repository at this point in the history
  • Loading branch information
larry authored and lyrra committed Nov 6, 2022
1 parent 3b54eed commit d0c0bbd
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion mscore/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ static const char* stateName(ViewState s)
// seqStopped
//---------------------------------------------------------

void ScoreView::seqStopped()
void ScoreView::seqStopped(unsigned int)
{
changeState(ViewState::NORMAL);
}
Expand Down
4 changes: 2 additions & 2 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1970,8 +1970,8 @@ MuseScore::MuseScore()
preferencesChanged();
MuxSeqSig* muxseqsig = muxseqsig_init();
if (muxseq_seq_alive()) {
connect(muxseqsig, SIGNAL(sigSeqStarted()), muxseqsig, SLOT(sigSeqStartedHandle()));
connect(muxseqsig, SIGNAL(sigSeqStopped()), muxseqsig, SLOT(sigSeqStoppedHandle()));
connect(muxseqsig, SIGNAL(sigSeqStarted(unsigned int)), muxseqsig, SLOT(sigSeqStartedHandle(unsigned int)));
connect(muxseqsig, SIGNAL(sigSeqStopped(unsigned int)), muxseqsig, SLOT(sigSeqStoppedHandle(unsigned int)));
connect(muxseqsig, SIGNAL(sigSeqUTick(unsigned int)), muxseqsig, SLOT(sigSeqUTickHandle(unsigned int)));
}
else {
Expand Down
3 changes: 1 addition & 2 deletions mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ ScoreView::ScoreView(QWidget* parent)
connect(getAction("loop"), SIGNAL(toggled(bool)), SLOT(loopToggled(bool)));
if (muxseq_seq_alive()) {
MuxSeqSig* muxseqsig = muxseqsig_get();
//FIX: isn't this already connected in musescore.cpp?
connect(muxseqsig, SIGNAL(sigSeqStopped()), SLOT(seqStopped()));
connect(muxseqsig, SIGNAL(sigSeqStopped(unsigned int)), SLOT(seqStopped(unsigned int)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion mscore/scoreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class ScoreView : public QWidget, public MuseScoreView {
void triggerCmdRealtimeAdvance();
void cmdRealtimeAdvance();
void extendCurrentNote();
void seqStopped();
void seqStopped(unsigned int);
void tripleClickTimeOut();

public slots:
Expand Down
2 changes: 1 addition & 1 deletion muxlib/muxseq_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ unsigned char* eventMap_to_muxbuffer(MuxseqMsgType type, EventMap evm,

int handle_mscore_msg_SeqStarted (Mux::MuxSocket &sock, struct MuxseqMsg msg)
{
muxseqsig_seq_emit_stopped(msg.payload.i);
muxseqsig_seq_emit_started(msg.payload.i);
strcpy(msg.label, "mscore");
if (mux_query_send(sock, &msg, sizeof(struct MuxseqMsg)) == -1) {
return -1;
Expand Down
35 changes: 16 additions & 19 deletions muxlib/muxseqsig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ MuxSeqSig::~MuxSeqSig()

// object signal emitters

void MuxSeqSig::emit_sigSeqStarted(unsigned int playframe) {
emit sigSeqStarted(playframe);
void MuxSeqSig::emit_sigSeqStarted(unsigned int utick) {
emit sigSeqStarted(utick);
}

void MuxSeqSig::emit_sigSeqStopped(unsigned int playframe) {
emit sigSeqStopped(playframe);
void MuxSeqSig::emit_sigSeqStopped(unsigned int utick) {
emit sigSeqStopped(utick);
}

void MuxSeqSig::emit_sigSeqUTick(unsigned int tick) {
qDebug("MuxSeqSig::emit_sigSeqUTick tick=%i", tick);
emit sigSeqUTick(tick);
void MuxSeqSig::emit_sigSeqUTick(unsigned int utick) {
emit sigSeqUTick(utick);
}

void MuxSeqSig::emit_gainChanged(float gain) {
Expand All @@ -45,17 +44,16 @@ void MuxSeqSig::emit_gainChanged(float gain) {

// functional signal emitters

void muxseqsig_seq_emit_started (uint64_t playframe) {
muxseqsig->emit_sigSeqStarted(playframe);
void muxseqsig_seq_emit_started (uint64_t utick) {
muxseqsig->emit_sigSeqStarted(utick);
}

void muxseqsig_seq_emit_stopped (uint64_t playframe) {
muxseqsig->emit_sigSeqStopped(playframe);
void muxseqsig_seq_emit_stopped (uint64_t utick) {
muxseqsig->emit_sigSeqStopped(utick);
}

void muxseqsig_seq_emit_utick (uint64_t tick) {
qDebug("muxseqsig_seq_emit_utick tick=%i", tick);
muxseqsig->emit_sigSeqUTick(tick);
void muxseqsig_seq_emit_utick (uint64_t utick) {
muxseqsig->emit_sigSeqUTick(utick);
}

void muxseqsig_emit_gainChanged (float gain) {
Expand All @@ -64,16 +62,15 @@ void muxseqsig_emit_gainChanged (float gain) {

// signal handlers

void MuxSeqSig::sigSeqStartedHandle(unsigned int playframe) {
mscore->seqStarted(playframe);
void MuxSeqSig::sigSeqStartedHandle(unsigned int utick) {
mscore->seqStarted(utick);
}

void MuxSeqSig::sigSeqStoppedHandle(unsigned int playframe) {
mscore->seqStopped(playframe);
void MuxSeqSig::sigSeqStoppedHandle(unsigned int utick) {
mscore->seqStopped(utick);
}

void MuxSeqSig::sigSeqUTickHandle(unsigned int utick) {
LD("MSCORE handle utick: %ld", utick);
mscore->handleUTick(utick);
}

Expand Down
24 changes: 12 additions & 12 deletions muxlib/muxseqsig.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ class MuxSeqSig : public QObject {

public:
~MuxSeqSig();
void emit_sigSeqStarted(unsigned int playframe);
void emit_sigSeqStopped(unsigned int playframe);
void emit_sigSeqUTick(unsigned int tick);
void emit_sigSeqStarted(unsigned int utick);
void emit_sigSeqStopped(unsigned int utick);
void emit_sigSeqUTick(unsigned int utick);
void emit_gainChanged(float gain);
public slots:
void setMetronomeGain(float gain);
void setRelTempo(double tempo);
void seek(int pos);
void sigSeqUTickHandle(unsigned int tick);
void sigSeqStartedHandle(unsigned int playframe);
void sigSeqStoppedHandle(unsigned int playframe);
void sigSeqStartedHandle(unsigned int utick);
void sigSeqStoppedHandle(unsigned int utick);
void sigSeqUTickHandle(unsigned int utick);

signals:
void sigSeqStarted(unsigned int playframe);
void sigSeqStopped(unsigned int playframe);
void sigSeqUTick(unsigned int tick);
void sigSeqStarted(unsigned int utick);
void sigSeqStopped(unsigned int utick);
void sigSeqUTick(unsigned int utick);
void gainChanged(float); // MasterSynthesizer
};

MuxSeqSig* muxseqsig_init();
MuxSeqSig* muxseqsig_get();
void muxseqsig_seq_emit_started(uint64_t playframe);
void muxseqsig_seq_emit_stopped(uint64_t playframe);
void muxseqsig_seq_emit_utick(uint64_t tick);
void muxseqsig_seq_emit_started(uint64_t utick);
void muxseqsig_seq_emit_stopped(uint64_t utick);
void muxseqsig_seq_emit_utick(uint64_t utick);
void muxseqsig_emit_gainChanged (float gain);

} // namespace Ms
Expand Down
6 changes: 6 additions & 0 deletions muxseq/muxseq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ int muxseq_handle_musescore_msg_MsgTypeSeqSeek (Mux::MuxSocket &sock, struct Mux
muxseq_msg_to_audio(MsgTypeTransportSeek, msg.payload.i);
return muxseq_handle_musescore_reply_int(sock, msg, 0);
}
int muxseq_handle_musescore_msg_MsgTypeSeqPlaying (Mux::MuxSocket &sock, struct MuxseqMsg msg) {
LD("MSCORE ==> MUXSEQ msg %s tick=%i", muxseq_msg_type_info(msg.type), msg.payload.i);
return muxseq_handle_musescore_reply_int(sock, msg, g_state_play ? 1 : 0);
}

int muxseq_handle_musescore_msg_MsgTypeMasterSynthInitInstruments(Mux::MuxSocket &sock, void *buf) {
unsigned char *ptr = (unsigned char*) buf;
Expand Down Expand Up @@ -412,6 +416,8 @@ int muxseq_handle_musescore_msg(Mux::MuxSocket &sock, void *buf)
return muxseq_handle_musescore_msg_MsgTypeSeqSeek(sock, msg);
case MsgTypeMasterSynthInitInstruments:
return muxseq_handle_musescore_msg_MsgTypeMasterSynthInitInstruments(sock, buf);
case MsgTypeSeqPlaying:
return muxseq_handle_musescore_msg_MsgTypeSeqPlaying(sock, msg);
default:
LD("ERROR: Unknown message: %s", muxseq_msg_type_info(msg.type));
break;
Expand Down

0 comments on commit d0c0bbd

Please sign in to comment.