Hi. My name is Pieter Nagel and here's a few patches.

But first, by way of introduction: I recently got back into MIDI
sequencing when I got myself a Roland Fantom. From all Linux sequencers I
looked at, Rosegarden seemed the most promising but there's still a few
features missing, so I want to contribute to this project. Last time I'd
worked with a MIDI sequencer was on a 386 DOS-based PC using Voyetra
something or another. I'm a professional programmer, I started out with
C++ but nowadays code mostly Python and Smalltalk, except when coding
extensions to Python in C++.

The patches add the ability to trigger Rosegarden to record via MMC. My
motivation is to get more and more control over Rosegarden without needing
to move between the Synth and the computer keyboard.

To get a feel for the kind of code you like in this project, I present
three different approaches:

1) The first approach is the simplest in terms of code: the Record Strobe
MMC message toggles record on Rosegarden's the transport. Pro: it's a
simple diff, and one button starts and stops record. Con: MMC defines
separate punch-in and punch-out messages, which differs from this
implementation; and also the AlsaDriver::testForMMCSysex() method is now
getting a lot of duplicate code.

Index: src/sound/AlsaDriver.cpp
===================================================================
--- src/sound/AlsaDriver.cpp    (revision 7807)
+++ src/sound/AlsaDriver.cpp    (working copy)
@@ -3259,6 +3259,11 @@
         if (transport) {
             transport->transportChange(ExternalTransport::TransportStop);
         }
+    } else if (instruction == MIDI_MMC_RECORD_STROBE) {
+        ExternalTransport *transport = getExternalTransportControl();
+        if (transport) {
+            transport->transportChange(ExternalTransport::TransportRecord);
+        }
     }
 
     return true;

===

2) Same implementation, but takes care of the
"getExternalTransportControl()", "if (transport)" and
"transport->transportChange" which each were triplicated:

Index: src/sound/AlsaDriver.cpp
===================================================================
--- src/sound/AlsaDriver.cpp    (revision 7807)
+++ src/sound/AlsaDriver.cpp    (working copy)
@@ -3248,19 +3248,27 @@
     if (*ptr != MIDI_END_OF_EXCLUSIVE)
         return false;
 
-    if (instruction == MIDI_MMC_PLAY ||
-            instruction == MIDI_MMC_DEFERRED_PLAY) {
-        ExternalTransport *transport = getExternalTransportControl();
-        if (transport) {
-            transport->transportChange(ExternalTransport::TransportPlay);
-        }
-    } else if (instruction == MIDI_MMC_STOP) {
-        ExternalTransport *transport = getExternalTransportControl();
-        if (transport) {
-            transport->transportChange(ExternalTransport::TransportStop);
-        }
+    ExternalTransport::TransportRequest request;
+    switch (instruction) {
+    case MIDI_MMC_PLAY:
+    case MIDI_MMC_DEFERRED_PLAY:
+       request = ExternalTransport::TransportPlay;
+       break;
+    case MIDI_MMC_STOP:
+       request = ExternalTransport::TransportStop;
+       break;
+    case MIDI_MMC_RECORD_STROBE:
+       request = ExternalTransport::TransportRecord;
+       break;
+    default:
+       request = ExternalTransport::TransportNoChange;
     }
 
+    ExternalTransport *transport = getExternalTransportControl();
+    if (transport) {
+       transport->transportChange(request);
+    }
+
     return true;
 }
 
===

3) Another aproach would be to add punch-in punch-out requests to
ExternalTransport, and teach transportChange to Do The Right Thing. But I
don't have access to the MMC spec, so I am not quite sure if this is the
right way to go. I could find the manual for a "MCS2 MIDI", and that
device gets by without ever sending punch-out at all.

If this is to be implemented, should I take the latter route?


-- 
     ,_
     /_)              /| /
    /   i e t e r    / |/ a g e l

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to