diff options
48 files changed, 77 insertions, 3357 deletions
diff --git a/muse/CMakeLists.txt b/muse/CMakeLists.txt index 9cfc9e12..e0de0c81 100644 --- a/muse/CMakeLists.txt +++ b/muse/CMakeLists.txt @@ -20,6 +20,9 @@  project(muse)  CMAKE_MINIMUM_REQUIRED(VERSION 2.4.1) +if (COMMAND cmake_policy) +      cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy)  # set libdir if not use -DCMAKE_INSTALL_LIBDIR  if (NOT CMAKE_INSTALL_LIBDIR) @@ -54,7 +57,7 @@ include ( ${PROJECT_SOURCE_DIR}/cmake/TargetDoc.cmake)  option ( ENABLE_DSSI        "enable Disposable Soft Synth Interface"  ON)  option ( ENABLE_VST         "enable VST/win support"                  OFF)  option ( ENABLE_FLUID       "enable fluidsynth softsynth plugins"     ON) -option ( ENABLE_ZYNADDSUBFX "enable zyaddsubfx softsynth plugin"      OFF) +option ( ENABLE_ZYNADDSUBFX "enable zyaddsubfx softsynth plugin"      ON)  ##  ## Just print a notice if this is OS X diff --git a/muse/ChangeLog b/muse/ChangeLog index 867d88f7..88d7a463 100644 --- a/muse/ChangeLog +++ b/muse/ChangeLog @@ -1,3 +1,7 @@ +25.6. (ws) +      As part of a major code cleanup i removed ALSA midi. This also removes the +      need for a realtime timer (JACK midi and MusE are competing for it) and simplifies +      a lot of other code.  2.3. (ws)        - dssi plugins: fix count of LADSPA ports  21.02. (fn) diff --git a/muse/README b/muse/README index 8620829e..26b1e7d4 100644 --- a/muse/README +++ b/muse/README @@ -27,9 +27,6 @@ details.          ftp://ftp.trolltech.com/qt/source          MusE does _not_ compile with older versions -      - ALSA 1.0 or newer -        http://www.alsa-project.org/ -        - gcc 4.x.x        - libsndfile >= 1.0.1 diff --git a/muse/muse/CMakeLists.txt b/muse/muse/CMakeLists.txt index c8496acd..68eeddaf 100644 --- a/muse/muse/CMakeLists.txt +++ b/muse/muse/CMakeLists.txt @@ -122,7 +122,6 @@ add_executable ( muse  	help.cpp  	midictrl.cpp        fifo.cpp -	midiseq.cpp        helper.cpp        route.cpp        shortcuts.cpp diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp index b2d54019..05442f96 100644 --- a/muse/muse/audio.cpp +++ b/muse/muse/audio.cpp @@ -25,11 +25,9 @@  #include "globals.h"  #include "song.h"  #include "driver/audiodev.h" -#include "driver/mididev.h"  #include "audioprefetch.h"  #include "audiowriteback.h"  #include "audio.h" -#include "midiseq.h"  #include "sync.h"  #include "midi.h"  #include "gconfig.h" @@ -141,7 +139,7 @@ bool Audio::start()        _seqTime.nextTickPos  = 0;        _seqTime.pos.setFrame(~0);      // make sure seek is not optimized away -      msg           = 0; +      msg = 0;        //        // init marker for synchronous loop processing @@ -159,7 +157,6 @@ bool Audio::start()                  (*i)->activate1();            seek(song->cpos());            process(segmentSize, STOP);   // warm up caches; audio must be stopped -          audioDriver->start(realTimePriority);            }        else { @@ -185,13 +182,13 @@ bool Audio::start()                            (*i)->setJackPort(Port(), x);  // zero out the old connection                        (*i)->activate1();                        } -               audioDriver->start(realTimePriority);                 }            else {                 printf("Failed to init audio!\n");                 return false;                 }            } +      audioDriver->start(realTimePriority);        audioDriver->stopTransport();        return true;        } @@ -511,7 +508,7 @@ void Audio::process(unsigned frames, int jackState)              _seqTime.pos       += frames;              _seqTime.curTickPos = _seqTime.nextTickPos;              } -      midiDriver->updateConnections(); +//      midiDriver->updateConnections();        }  //--------------------------------------------------------- @@ -567,10 +564,6 @@ void Audio::processMsg()                    idle = msg->a;                    break; -            case MS_SET_RTC: -                  midiSeq->initRealtimeTimer(); -                  break; -              case AUDIO_ADDMIDIPLUGIN:                    ((MidiTrackBase*)msg->track)->addPlugin(msg->mplugin, msg->ival);                    break; diff --git a/muse/muse/audioprefetch.cpp b/muse/muse/audioprefetch.cpp index 7f6711f7..d433c1ac 100644 --- a/muse/muse/audioprefetch.cpp +++ b/muse/muse/audioprefetch.cpp @@ -134,7 +134,9 @@ void AudioPrefetch::msgSeek(unsigned samplePos)        if (samplePos == seekPos)              return; -      q_atomic_increment(&seekCount); +      //q_atomic_increment(&seekCount); +      ++seekCount; +        PrefetchMsg msg;        msg.id  = PREFETCH_SEEK;        msg.pos = samplePos; @@ -191,6 +193,7 @@ void AudioPrefetch::seek(unsigned seekTo)        writePos = seekTo;  	prefetch(true);        seekPos = seekTo; -      q_atomic_decrement(&seekCount); +      // q_atomic_decrement(&seekCount); +      --seekCount;        } diff --git a/muse/muse/audiotrack.cpp b/muse/muse/audiotrack.cpp index 3fa59e4f..375efd6e 100644 --- a/muse/muse/audiotrack.cpp +++ b/muse/muse/audiotrack.cpp @@ -398,13 +398,10 @@ void AudioTrack::record()  void AudioTrack::setChannels(int n)        { -printf("setChannels %d\n", n); -        if (n > MAX_CHANNELS) {              fprintf(stderr, "AudioTrack::setChannels(%d): too many channels(>%d)!\n",                 n, MAX_CHANNELS);              n = MAX_CHANNELS; -abort();              }        Track::setChannels(n);        if (_prePipe) diff --git a/muse/muse/audiowriteback.cpp b/muse/muse/audiowriteback.cpp index 87b8f72f..391c89bd 100644 --- a/muse/muse/audiowriteback.cpp +++ b/muse/muse/audiowriteback.cpp @@ -65,7 +65,9 @@ void AudioWriteback::start(int priority)  void AudioWriteback::processMsg1(const void*)        {        while (counter) { -            q_atomic_decrement(&counter); +            //q_atomic_decrement(&counter); +            --counter; +        	OutputList* ol = song->outputs();        	if (!ol->empty()) {              	AudioOutput* ao = ol->front(); @@ -88,7 +90,8 @@ void AudioWriteback::processMsg1(const void*)  void AudioWriteback::trigger()  	{ -	q_atomic_increment(&counter); +	// q_atomic_increment(&counter); +      ++counter;        if (counter < 2) {        	if (sendMsg1("0", 1)) {              	printf("AudioWriteback::msgTick(): send failed!\n"); diff --git a/muse/muse/driver/CMakeLists.txt b/muse/muse/driver/CMakeLists.txt index 3b337481..80612301 100644 --- a/muse/muse/driver/CMakeLists.txt +++ b/muse/muse/driver/CMakeLists.txt @@ -9,8 +9,7 @@ set ( driver_src        )  ELSE (APPLE)  set ( driver_src -     alsamidi.cpp jack.cpp dummyaudio.cpp alsatimer.cpp -      rtctimer.cpp posixtimer.cpp +      jack.cpp dummyaudio.cpp        )  ENDIF (APPLE) diff --git a/muse/muse/driver/alsamidi.cpp b/muse/muse/driver/alsamidi.cpp deleted file mode 100644 index f8133bd7..00000000 --- a/muse/muse/driver/alsamidi.cpp +++ /dev/null @@ -1,727 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "alsamidi.h" -#include "globals.h" -#include "midi.h" -#include "midiinport.h" -#include "midioutport.h" -#include "../midiseq.h" -#include "../song.h" -#include "al/pos.h" - -static const unsigned int inCap  = SND_SEQ_PORT_CAP_SUBS_READ; -static const unsigned int outCap = SND_SEQ_PORT_CAP_SUBS_WRITE; - -AlsaMidi alsaMidi; -AlsaMidi* midiDriver; - -//--------------------------------------------------------- -//   put -//    return true on fifo overflow -//--------------------------------------------------------- - -bool PortRouteFifo::put(const PortRoute& event) -      { -      if (size < PORT_ROUTE_FIFO_SIZE) { -            fifo[wIndex] = event; -            wIndex = (wIndex + 1) % PORT_ROUTE_FIFO_SIZE; -            q_atomic_increment(&size); -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   get -//--------------------------------------------------------- - -PortRoute PortRouteFifo::get() -      { -      PortRoute event(fifo[rIndex]); -      rIndex = (rIndex + 1) % PORT_ROUTE_FIFO_SIZE; -      q_atomic_decrement(&size); -      return event; -      } - -//--------------------------------------------------------- -//   AlsaMidi -//--------------------------------------------------------- - -AlsaMidi::AlsaMidi() -      { -      alsaSeq = 0; -      } - -//--------------------------------------------------------- -//   init -//    return true on error -//--------------------------------------------------------- - -bool AlsaMidi::init() -      { -      if (debugMsg) -            printf("init AlsaMidi\n"); -      int error = snd_seq_open(&alsaSeq, "hw", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK); -      if (error < 0) { -            if (error == ENOENT) -            fprintf(stderr, "open ALSA sequencer failed: %s\n", -               snd_strerror(error)); -            return true; -            } - -      snd_seq_set_client_name(alsaSeq, "MusE Sequencer"); - -      //----------------------------------------- -      //    subscribe to "Announce" -      //    this enables callbacks for any -      //    alsa port changes -      //----------------------------------------- - -      snd_seq_addr_t src, dst; -      int rv = snd_seq_create_simple_port(alsaSeq, "MusE Port 0", -         inCap | outCap | SND_SEQ_PORT_CAP_READ -         | SND_SEQ_PORT_CAP_WRITE -         | SND_SEQ_PORT_CAP_NO_EXPORT, -         SND_SEQ_PORT_TYPE_APPLICATION); -      if (rv < 0) { -            fprintf(stderr, "Alsa: create MusE port failed: %s\n", snd_strerror(error)); -            exit(1); -            } -      dst.port   = rv; -      dst.client = snd_seq_client_id(alsaSeq); -      src.port   = SND_SEQ_PORT_SYSTEM_ANNOUNCE; -      src.client = SND_SEQ_CLIENT_SYSTEM; - -      snd_seq_port_subscribe_t* subs; -      snd_seq_port_subscribe_alloca(&subs); -      snd_seq_port_subscribe_set_dest(subs, &dst); -      snd_seq_port_subscribe_set_sender(subs, &src); -      error = snd_seq_subscribe_port(alsaSeq, subs); -      if (error < 0) { -            fprintf(stderr, "Alsa: Subscribe System failed: %s\n", snd_strerror(error)); -            return true; -            } - -      return false; -      } - -//--------------------------------------------------------- -//   outputPorts -//--------------------------------------------------------- - -QList<PortName> AlsaMidi::outputPorts(bool) -      { -      QList<PortName> clientList; -      snd_seq_client_info_t* cinfo; -      snd_seq_client_info_alloca(&cinfo); -      snd_seq_client_info_set_client(cinfo, 0); - -      while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { -            snd_seq_port_info_t *pinfo; -            snd_seq_port_info_alloca(&pinfo); -            snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); -            snd_seq_port_info_set_port(pinfo, -1); -            while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { -                  unsigned int capability = snd_seq_port_info_get_capability(pinfo); -                  if (((capability & outCap) == outCap) -                     && !(capability & SND_SEQ_PORT_CAP_NO_EXPORT)) { -                        int client = snd_seq_port_info_get_client(pinfo); -                        if (client != snd_seq_client_id(alsaSeq)) { -                              PortName pn; -                              pn.name = QString(snd_seq_port_info_get_name(pinfo)); -                              pn.port = Port(client, snd_seq_port_info_get_port(pinfo)); -                              clientList.append(pn); -                              } -                        } -                  } -            } -      return clientList; -      } - -//--------------------------------------------------------- -//   inputPorts -//--------------------------------------------------------- - -QList<PortName> AlsaMidi::inputPorts(bool) -      { -      QList<PortName> clientList; - -      snd_seq_client_info_t* cinfo; -      snd_seq_client_info_alloca(&cinfo); -      snd_seq_client_info_set_client(cinfo, 0); - -      while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { -            snd_seq_port_info_t *pinfo; -            snd_seq_port_info_alloca(&pinfo); -            snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); -            snd_seq_port_info_set_port(pinfo, -1); -            while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { -                  unsigned int capability = snd_seq_port_info_get_capability(pinfo); -                  if (((capability & inCap) == inCap) -                     && !(capability & SND_SEQ_PORT_CAP_NO_EXPORT)) { -                        int client = snd_seq_port_info_get_client(pinfo); -                        if (client != snd_seq_client_id(alsaSeq)) { -                              PortName pn; -                              pn.name = QString(snd_seq_port_info_get_name(pinfo)); -                              pn.port = Port(client, snd_seq_port_info_get_port(pinfo)); -                              clientList.append(pn); -                              } -                        } -                  } -            } -      return clientList; -      } - -//--------------------------------------------------------- -//   registerOutPort -//--------------------------------------------------------- - -Port AlsaMidi::registerOutPort(const QString& name, bool) -      { -      int alsaPort  = snd_seq_create_simple_port(alsaSeq, name.toLatin1().data(), -         outCap | SND_SEQ_PORT_CAP_WRITE, SND_SEQ_PORT_TYPE_APPLICATION); -      if (alsaPort < 0) { -            perror("cannot create alsa out port"); -            return Port(); -            } -      return Port(snd_seq_client_id(alsaSeq), alsaPort); -      } - -//--------------------------------------------------------- -//   registerInPort -//--------------------------------------------------------- - -Port AlsaMidi::registerInPort(const QString& name, bool) -      { -      int alsaPort  = snd_seq_create_simple_port(alsaSeq, name.toLatin1().data(), -         inCap | SND_SEQ_PORT_CAP_READ, SND_SEQ_PORT_TYPE_APPLICATION); -      if (alsaPort < 0) { -            perror("cannot create alsa in port"); -            return Port(); -            } -      return Port(snd_seq_client_id(alsaSeq), alsaPort); -      } - -//--------------------------------------------------------- -//   unregisterPort -//--------------------------------------------------------- - -void AlsaMidi::unregisterPort(Port port) -      { -      snd_seq_delete_simple_port(alsaSeq, port.alsaPort()); -      } - -//--------------------------------------------------------- -//   setPortName -//--------------------------------------------------------- - -void AlsaMidi::setPortName(Port, const QString& name) -      { -      printf("AlsaMidi::setPortName(%s): not impl.\n", name.toLatin1().data()); -      } - -//--------------------------------------------------------- -//   portName -//--------------------------------------------------------- - -QString AlsaMidi::portName(Port p) -      { -      snd_seq_port_info_t* pinfo; -      snd_seq_port_info_alloca(&pinfo); -      snd_seq_get_any_port_info(alsaSeq, p.alsaClient(), p.alsaPort(), pinfo); -      return QString(snd_seq_port_info_get_name(pinfo)); -      } - -//--------------------------------------------------------- -//   findPort -//--------------------------------------------------------- - -Port AlsaMidi::findPort(const QString& name) -      { -      snd_seq_client_info_t* cinfo; -      snd_seq_client_info_alloca(&cinfo); -      snd_seq_client_info_set_client(cinfo, 0); - -      while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { -            snd_seq_port_info_t *pinfo; -            snd_seq_port_info_alloca(&pinfo); -            snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); -            snd_seq_port_info_set_port(pinfo, -1); -            while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { -                  const char* pn = snd_seq_port_info_get_name(pinfo); -                  if (name == pn) { -                        return Port(snd_seq_port_info_get_client(pinfo), -                           snd_seq_port_info_get_port(pinfo)); -                        } -                  } -            } -      printf("AlsaMidi: port <%s> not found\n", name.toLatin1().data()); -      return Port(); -      } - -//--------------------------------------------------------- -//   connect -//    return false if connect fails -//--------------------------------------------------------- - -bool AlsaMidi::connect(Port src, Port dst) -      { -      snd_seq_port_subscribe_t* sub; -      snd_seq_port_subscribe_alloca(&sub); - -      snd_seq_addr_t s, d; -      s.port   = src.alsaPort(); -      s.client = src.alsaClient(); -      d.port   = dst.alsaPort(); -      d.client = dst.alsaClient(); -      snd_seq_port_subscribe_set_sender(sub, &s); -      snd_seq_port_subscribe_set_dest(sub, &d); - -      int rv = snd_seq_subscribe_port(alsaSeq, sub); -      if (rv < 0) { -            printf("AlsaMidi::connect(%d:%d, %d:%d) failed: %s\n", -               src.alsaClient(), src.alsaPort(), -               dst.alsaClient(), dst.alsaPort(), -               snd_strerror(rv)); -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   disconnect -//    return false if disconnect fails -//--------------------------------------------------------- - -bool AlsaMidi::disconnect(Port src, Port dst) -      { -      snd_seq_port_subscribe_t* sub; -      snd_seq_port_subscribe_alloca(&sub); -      snd_seq_addr_t s, d; -      s.port   = src.alsaPort(); -      s.client = src.alsaClient(); -      d.port   = dst.alsaPort(); -      d.client = dst.alsaClient(); -      snd_seq_port_subscribe_set_sender(sub, &s); -      snd_seq_port_subscribe_set_dest(sub, &d); -      int rv = snd_seq_unsubscribe_port(alsaSeq, sub); -      if (rv < 0) -            printf("AlsaMidi::disconnect() failed: %s\n", -               snd_strerror(rv)); -      return rv >= 0; -      } - -//--------------------------------------------------------- -//   getInputPollFd -//--------------------------------------------------------- - -void AlsaMidi::getInputPollFd(struct pollfd** p, int* n) -      { -      int npfdi = snd_seq_poll_descriptors_count(alsaSeq, POLLIN); -      struct pollfd* pfdi  = new struct pollfd[npfdi]; -      snd_seq_poll_descriptors(alsaSeq, pfdi, npfdi, POLLIN); -      *p = pfdi; -      *n = npfdi; -      } - -//--------------------------------------------------------- -//   getOutputPollFd -//--------------------------------------------------------- - -void AlsaMidi::getOutputPollFd(struct pollfd** p, int* n) -      { -      int npfdo = snd_seq_poll_descriptors_count(alsaSeq, POLLOUT); -      struct pollfd* pfdo  = new struct pollfd[npfdo]; -      snd_seq_poll_descriptors(alsaSeq, pfdo, npfdo, POLLOUT); -      *p = pfdo; -      *n = npfdo; -      } - -//--------------------------------------------------------- -//   addConnection -//    a new connection was added -//    called in MidiSeq context, FIFO synchronizes with -//    JACK callback -//--------------------------------------------------------- - -void AlsaMidi::addConnection(snd_seq_connect_t* ev) -      { -      Port rs(ev->sender.client, ev->sender.port); -      Port rd(ev->dest.client, ev->dest.port); -      PortRoute pr; -      pr.src = rs; -      pr.dst = rd; -      addCon.put(pr); -      } - -//--------------------------------------------------------- -//   removeConnection -//    a connection was removed -//    called in MidiSeq context, FIFO synchronizes with -//    JACK callback -//--------------------------------------------------------- - -void AlsaMidi::removeConnection(snd_seq_connect_t* ev) -      { -      Port rs(ev->sender.client, ev->sender.port); -      Port rd(ev->dest.client, ev->dest.port); -      PortRoute pr; -      pr.src = rs; -      pr.dst = rd; -      removeCon.put(pr); -      } - -//--------------------------------------------------------- -//   read -//    read ALSA midi events -//    This is called by the high priority RT MidiSeq -//    thread. -//--------------------------------------------------------- - -void AlsaMidi::read(MidiSeq* /*seq*/) -      { -      snd_seq_event_t* ev; -      for (int i = 0;; ++i) { -            int rv = snd_seq_event_input(alsaSeq, &ev); -            if (rv <= 0) { -                  if (rv < 0 && rv != -11)   // Resource temporarily unavailable -                        printf("AlsaMidi: read error 0x%x %s\n", rv, snd_strerror(rv)); -                  break; -                  } -// printf("Alsa midi event %d %d\n", rv, ev->type); - -            switch(ev->type) { -                  case SND_SEQ_EVENT_PORT_SUBSCRIBED: -                        // printf("subscribe\n"); -                        addConnection((snd_seq_connect_t*)(&ev->data)); -                        break; -                  case SND_SEQ_EVENT_PORT_UNSUBSCRIBED: -                        // printf("unsubscribe\n"); -                        removeConnection((snd_seq_connect_t*)(&ev->data)); -                        break; -                  case SND_SEQ_EVENT_CLIENT_START: -                        // printf("client start\n"); -                        break; -                  case SND_SEQ_EVENT_CLIENT_EXIT: -                        // printf("client exit\n"); -                        break; -                  case SND_SEQ_EVENT_PORT_START: -                        // printf("port start\n"); -                        break; -                  case SND_SEQ_EVENT_PORT_EXIT: -                        // printf("port exit\n"); -                        break; -                  case SND_SEQ_EVENT_SYSEX: -                  	{ -                        // -                        // look for Midi Machine Control events (MMC) -                        // -                        unsigned char* data = ((unsigned char*)ev->data.ext.ptr) + 1; -                        int len = ev->data.ext.len - 2; -                        if ((len == 4) && (data[0] == 0x7f) && (data[2] == 0x06)) { -//TODO                              seq->mmcInput(data[1], data[3], 0); -                              break; -                              } -                        if ((len == 11) && (data[0] == 0x7f) -                           && (data[2] == 0x06) -                           && (data[3] == 0x44) && (data[4] == 0x06) -                           && (data[5] == 0x1)) { -                              int h = data[6]; -                              int m = data[7]; -                              int s = data[8]; -                              int f = data[9]; -                              int sf = data[10]; -                              AL::Pos pos(h * 60 + m, s, f, sf); -//TODO                              seq->mmcInput(data[1], data[3], pos); -                              break; -                              } -                        } - -                  case SND_SEQ_EVENT_KEYPRESS: -                  case SND_SEQ_EVENT_CHANPRESS: -                  case SND_SEQ_EVENT_NOTEON: -                  case SND_SEQ_EVENT_NOTEOFF: -                  case SND_SEQ_EVENT_PGMCHANGE: -                  case SND_SEQ_EVENT_PITCHBEND: -                  case SND_SEQ_EVENT_CONTROLLER: -                        { -                        Port port(ev->dest.client, ev->dest.port); - -                        MidiInPortList* mpl = song->midiInPorts(); -                        for (iMidiInPort i = mpl->begin(); i != mpl->end(); ++i) { -                              MidiInPort* inPort = *i; -                              if (port == inPort->alsaPort()) { -                                    inPort->eventReceived(ev); -                                    } -                              } -                        } -                        break; - -                  case SND_SEQ_EVENT_CLOCK: -//TODO                        seq->realtimeSystemInput(0, 0xf8); -                        break; -                  case SND_SEQ_EVENT_START: -//TODO                        seq->realtimeSystemInput(0, 0xfa); -                        break; -                  case SND_SEQ_EVENT_CONTINUE: -//TODO                        seq->realtimeSystemInput(0, 0xfb); -                        break; -                  case SND_SEQ_EVENT_STOP: -//TODO                        seq->realtimeSystemInput(0, 0xfc); -                        break; -                  case SND_SEQ_EVENT_TICK: -//TODO                        seq->realtimeSystemInput(0, 0xf9); -                        break; -                  case SND_SEQ_EVENT_SONGPOS: -//TODO                        seq->setSongPosition(0, ev->data.control.value); -                        break; -                  case SND_SEQ_EVENT_SENSING: -                        break; -                  case SND_SEQ_EVENT_QFRAME: -//TODO                        seq->mtcInputQuarter(0, ev->data.control.value); -                        break; -                  // case SND_SEQ_EVENT_CLIENT_START: -                  // case SND_SEQ_EVENT_CLIENT_EXIT: -                  // case SND_SEQ_EVENT_CLIENT_CHANGE: -                  // case SND_SEQ_EVENT_PORT_CHANGE: -                  // case SND_SEQ_EVENT_SONGSEL: -                  // case SND_SEQ_EVENT_TIMESIGN: -                  // case SND_SEQ_EVENT_KEYSIGN: -                  // case SND_SEQ_EVENT_SETPOS_TICK: -                  // case SND_SEQ_EVENT_SETPOS_TIME: -                  // case SND_SEQ_EVENT_TEMPO: -                  // case SND_SEQ_EVENT_TUNE_REQUEST: -                  // case SND_SEQ_EVENT_RESET: -                  // case SND_SEQ_EVENT_NOTE: -                  // case SND_SEQ_EVENT_CONTROL14: -                  // case SND_SEQ_EVENT_NONREGPARAM: -                  // case SND_SEQ_EVENT_REGPARAM: -                  default: -                        printf("ALSA Midi input: type %d not handled\n", ev->type); -                        break; -                  } -            snd_seq_free_event(ev); -            } -      } - -//--------------------------------------------------------- -//   write -//--------------------------------------------------------- - -void AlsaMidi::write() -      { -      } - -//--------------------------------------------------------- -//   putEvent -//--------------------------------------------------------- - -void AlsaMidi::putEvent(Port p, const MidiEvent& e) -      { -      if (midiOutputTrace) { -            printf("MidiOut<%s>: midiAlsa: ", portName(p).toLatin1().data()); -            e.dump(); -            } -      int chn = e.channel(); -      int a   = e.dataA(); -      int b   = e.dataB(); - -      snd_seq_event_t event; -      memset(&event, 0, sizeof(event)); -      snd_seq_ev_set_direct(&event); -      snd_seq_ev_set_source(&event, p.alsaPort()); -      snd_seq_ev_set_dest(&event, SND_SEQ_ADDRESS_SUBSCRIBERS, 0); - -      switch(e.type()) { -            case ME_NOTEON: -                  snd_seq_ev_set_noteon(&event, chn, a, b); -                  break; -            case ME_NOTEOFF: -                  snd_seq_ev_set_noteoff(&event, chn, a, 0); -                  break; -            case ME_PROGRAM: -                  snd_seq_ev_set_pgmchange(&event, chn, a); -                  break; -            case ME_CONTROLLER: -                  snd_seq_ev_set_controller(&event, chn, a, b); -                  break; -            case ME_PITCHBEND: -                  snd_seq_ev_set_pitchbend(&event, chn, a); -                  break; -            case ME_POLYAFTER: -                  // chnEvent2(chn, 0xa0, a, b); -                  break; -            case ME_AFTERTOUCH: -                  snd_seq_ev_set_chanpress(&event, chn, a); -                  break; -            case ME_SYSEX: -                  { -                  const unsigned char* p = e.data(); -                  int n                  = e.len(); -                  int len                = n + sizeof(event) + 2; -                  char buf[len]; -                  event.type             = SND_SEQ_EVENT_SYSEX; -                  event.flags            = SND_SEQ_EVENT_LENGTH_VARIABLE; -                  event.data.ext.len     = n + 2; -                  event.data.ext.ptr  = (void*)(buf + sizeof(event)); -                  memcpy(buf, &event, sizeof(event)); -                  char* pp = buf + sizeof(event); -                  *pp++ = 0xf0; -                  memcpy(pp, p, n); -                  pp += n; -                  *pp = 0xf7; -                  putEvent(&event); -                  return; -                  } -            case ME_SONGPOS: -                  event.data.control.value = a; -                  event.type = SND_SEQ_EVENT_SONGPOS; -                  break; -            case ME_CLOCK: -                  event.type = SND_SEQ_EVENT_CLOCK; -                  break; -            case ME_START: -                  event.type = SND_SEQ_EVENT_START; -                  break; -            case ME_CONTINUE: -                  event.type = SND_SEQ_EVENT_CONTINUE; -                  break; -            case ME_STOP: -                  event.type = SND_SEQ_EVENT_STOP; -                  break; -            default: -                  printf("MidiAlsaDevice::putEvent(): event type %d not implemented\n", -                     e.type()); -                  return; -            } -      putEvent(&event); -      } - -//--------------------------------------------------------- -//   putEvent -//    return false if event is delivered -//--------------------------------------------------------- - -bool AlsaMidi::putEvent(snd_seq_event_t* event) -      { -      int error; - -      do { -            error   = snd_seq_event_output_direct(alsaSeq, event); -            int len = snd_seq_event_length(event); -            if (error == len) { -                  return false; -                  } -            if (error < 0) { -                  if (error == -12) { -                        return true; -                        } -                  else { -                        fprintf(stderr, "MidiAlsaDevice::%p putEvent(): midi write error: %s\n", -                           this, snd_strerror(error)); -                        //exit(-1); -                        } -                  } -            else -                  fprintf(stderr, "MidiAlsaDevice::putEvent(): midi write returns %d, expected %d: %s\n", -                     error, len, snd_strerror(error)); -            } while (error == -12); -      return true; -      } - -//--------------------------------------------------------- -//   updateConnections -//    this is called in JACK callback context -//--------------------------------------------------------- - -void AlsaMidi::updateConnections() -      { -      // -      //  add connections -      // -      while (!addCon.isEmpty()) { -            PortRoute pr = addCon.get(); -            MidiOutPortList* opl = song->midiOutPorts(); -            for (iMidiOutPort i = opl->begin(); i != opl->end(); ++i) { -                  MidiOutPort* oport = *i; -                  Port sPort = oport->alsaPort(0); - -                  if (sPort == pr.src) { -                        RouteNode src(oport); -                        RouteNode dst(pr.dst, -1, RouteNode::MIDIPORT); -                        Route r = Route(src, dst); -                        if (oport->outRoutes()->indexOf(r) == -1) -                              oport->outRoutes()->push_back(r); -                        break; -                        } -                  } - -            MidiInPortList* ipl = song->midiInPorts(); -            for (iMidiInPort i = ipl->begin(); i != ipl->end(); ++i) { -                  MidiInPort* iport = *i; -                  Port dPort = iport->alsaPort(0); - -                  if (dPort == pr.dst) { -                        RouteNode src(pr.src, -1, RouteNode::MIDIPORT); -                        RouteNode dst(iport); -                        Route r = Route(src, dst); -                        if (!iport->inRouteExists(r)) -                              iport->addInRoute(r); -                        break; -                        } -                  } -            } -      // -      //  remove connections -      // -      while (!removeCon.isEmpty()) { -            PortRoute pr = removeCon.get(); - -            foreach(MidiInPort* iport, *(song->midiInPorts())) { -                  Port dst = iport->alsaPort(); -                  if (dst == pr.dst) { -                        RouteList* irl = iport->inRoutes(); -                        for (iRoute r = irl->begin(); r != irl->end(); ++r) { -                              if (r->src.port == pr.src) { -                                    iport->inRoutes()->erase(r); -                                    break; -                                    } -                              } -                        break; -                        } -                  } - -            foreach(MidiOutPort* oport, *(song->midiOutPorts())) { -                  Port src = oport->alsaPort(); -                  if (src == pr.src) { -                        RouteList* orl = oport->outRoutes(); -                        for (iRoute r = orl->begin(); r != orl->end(); ++r) { -                              if (r->dst.port == pr.dst) { -                                    orl->erase(r); -                                    break; -                                    } -                              } -                        break; -                        } -                  } -            } -      } - diff --git a/muse/muse/driver/alsamidi.h b/muse/muse/driver/alsamidi.h deleted file mode 100644 index 3073b63e..00000000 --- a/muse/muse/driver/alsamidi.h +++ /dev/null @@ -1,101 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __ALSAMIDI_H__ -#define __ALSAMIDI_H__ - -#include <alsa/asoundlib.h> -#include "driver.h" - -class MidiSeq; -class MidiEvent; - -#define PORT_ROUTE_FIFO_SIZE  16 - -//--------------------------------------------------------- -//   PortRoute -//--------------------------------------------------------- - -struct PortRoute { -      Port src, dst; -      }; - -//--------------------------------------------------------- -//   PortRouteFifo -//--------------------------------------------------------- - -class PortRouteFifo { -      PortRoute fifo[PORT_ROUTE_FIFO_SIZE]; -      volatile int size; -      int wIndex; -      int rIndex; - -   public: -      PortRouteFifo()  { clear(); } -      bool put(const PortRoute& event);   // returns true on fifo overflow -      PortRoute get(); -      bool isEmpty() const { return size == 0; } -      void clear()         { size = 0, wIndex = 0, rIndex = 0; } -      }; - -//--------------------------------------------------------- -//   AlsaMidi -//--------------------------------------------------------- - -class AlsaMidi : public Driver { -      snd_seq_t* alsaSeq; - -      void removeConnection(snd_seq_connect_t* ev); -      void addConnection(snd_seq_connect_t* ev); -      bool putEvent(snd_seq_event_t* event); - -      PortRouteFifo addCon; -      PortRouteFifo removeCon; - -   public: -      AlsaMidi(); -      virtual bool init(); - -      virtual QList<PortName> outputPorts(bool midi); -      virtual QList<PortName> inputPorts(bool midi); - -      virtual Port registerOutPort(const QString& name, bool midi); -      virtual Port registerInPort(const QString& name, bool midi); -      virtual void unregisterPort(Port); -      virtual void setPortName(Port p, const QString& n); -      virtual QString portName(Port); -      virtual Port findPort(const QString& name); - -      virtual bool connect(Port, Port); -      virtual bool disconnect(Port, Port); -      virtual void putEvent(Port, const MidiEvent&); - -      void getInputPollFd(struct pollfd**, int* n); -      void getOutputPollFd(struct pollfd**, int* n); - -      void read(MidiSeq*);      // process events -      void write(); -      void updateConnections(); -      }; - -extern AlsaMidi alsaMidi; -extern AlsaMidi* midiDriver; -#endif - diff --git a/muse/muse/driver/alsatimer.cpp b/muse/muse/driver/alsatimer.cpp deleted file mode 100644 index 9aae9f10..00000000 --- a/muse/muse/driver/alsatimer.cpp +++ /dev/null @@ -1,200 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Plenty of code borrowed from timer.c example in -//  alsalib 1.0.7 -// -//  (C) Copyright 2004 Robert Jonsson (rj@spamatica.se) -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "alsatimer.h" - - -AlsaTimer::AlsaTimer() -      { -      handle = 0; -      id     = 0; -      info   = 0; -      params = 0; -      } - -//--------------------------------------------------------- -//   ~AlsaTimer -//--------------------------------------------------------- - -AlsaTimer::~AlsaTimer() -      { -      if (handle) -            snd_timer_close(handle); -      if (id) -            free(id); -      if (info) -            free(info); -      if (params) -            free(params); -      } - -//--------------------------------------------------------- -//   initTimer -//--------------------------------------------------------- - -bool AlsaTimer::initTimer() -      { -      int err; -      int devclass = SND_TIMER_CLASS_GLOBAL; -      int sclass = SND_TIMER_CLASS_NONE; -      int card = 0; -      int device = SND_TIMER_GLOBAL_SYSTEM; -      int subdevice = 0; - -      if (id || info || params) -            return true; - -      snd_timer_id_malloc(&id); -      snd_timer_info_malloc(&info); -      snd_timer_params_malloc(¶ms); - - -      sprintf(timername, "hw:CLASS=%i,SCLASS=%i,CARD=%i,DEV=%i,SUBDEV=%i", devclass, sclass, card, device, subdevice); -      if ((err = snd_timer_open(&handle, timername, SND_TIMER_OPEN_NONBLOCK))<0) { -            fprintf(stderr, "AlsaTimer::initTimer(): timer open %i (%s)\n", err, snd_strerror(err)); -            } - -      if ((err = snd_timer_info(handle, info)) < 0) { -            fprintf(stderr, "AlsaTimer::initTimer(): timer info %i (%s)\n", err, snd_strerror(err)); -            return false; -            } - -      snd_timer_params_set_auto_start(params, 1); -      snd_timer_params_set_ticks(params, 1); - -      if ((err = snd_timer_params(handle, params)) < 0) { -            fprintf(stderr, "AlsaTimer::initTimer(): timer params %i (%s)\n", err, snd_strerror(err)); -            return false; -            } - -      count = snd_timer_poll_descriptors_count(handle); -      fds = (pollfd *)calloc(count, sizeof(pollfd)); -      if (fds == 0) { -            fprintf(stderr, "mAlsaTimer::initTimer(): alloc error\n"); -            return false; -            } -      if ((err = snd_timer_poll_descriptors(handle, fds, count)) < 0) { -            fprintf(stderr, "AlsaTimer::initTimer(): snd_timer_poll_descriptors error: %s\n", snd_strerror(err)); -            return false; -            } -      return true; -      } - - -//--------------------------------------------------------- -//   setTimerTicks -//--------------------------------------------------------- - -bool AlsaTimer::setTimerFreq(unsigned int freq) -    { -    signed int err; -    unsigned int setTick, actFreq; - -    if(TIMER_DEBUG) -      printf("AlsaTimer::setTimerFreq(this=%p)\n",this); - -    setTick = (1000000000 / snd_timer_info_get_resolution(info)) / freq; - -    if (setTick == 0) { -      fprintf(stderr,"AlsaTimer::setTimerTicks(): requested freq %u Hz too high for timer (max is %g)\n", -        freq, 1000000000.0 / snd_timer_info_get_resolution(info)); -      fprintf(stderr,"  freq stays at %ld Hz\n",(1000000000 / snd_timer_info_get_resolution(info)) / snd_timer_params_get_ticks(params)); - -      return true; -    } -    actFreq = (1000000000 / snd_timer_info_get_resolution(info)) / setTick; -    if (actFreq != freq) { -      fprintf(stderr,"AlsaTimer::setTimerTicks(): warning: requested %u Hz, actual freq is %u Hz\n", -        freq, actFreq); -    } -    if(TIMER_DEBUG) -      printf("AlsaTimer::setTimerFreq(): Setting ticks (period) to %d ticks\n", setTick); -    snd_timer_params_set_auto_start(params, 1); -    snd_timer_params_set_ticks(params, setTick); -    if ((err = snd_timer_params(handle, params)) < 0) { -      fprintf(stderr, "AlsaTimer::setTimerFreq(): timer params %i (%s)\n", err, snd_strerror(err)); -      return false; -      } - -    return true; -    } - -//--------------------------------------------------------- -//   getTimerResolution -//--------------------------------------------------------- - -int  AlsaTimer::getTimerResolution() -      { -      return  snd_timer_info_get_resolution(info); -      } - -//--------------------------------------------------------- -//   getTimerFreq -//--------------------------------------------------------- - -unsigned int AlsaTimer::getTimerFreq() -    { -    return (1000000000 / snd_timer_info_get_resolution(info)) / snd_timer_params_get_ticks(params); -    } - -//--------------------------------------------------------- -//   startTimer -//--------------------------------------------------------- - -bool AlsaTimer::startTimer() -      { -      int err; -      if ((err = snd_timer_start(handle)) < 0) { -            fprintf(stderr, "AlsaTimer::startTimer(): timer start %i (%s)\n", err, snd_strerror(err)); -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   stopTimer -//--------------------------------------------------------- - -bool AlsaTimer::stopTimer() -    { -      int err; -      if ((err = snd_timer_stop(handle)) < 0) { -            fprintf(stderr, "AlsaTimer::startTimer(): timer stop %i (%s)\n", err, snd_strerror(err)); -            return false; -            } -      snd_timer_close(handle); -      return true; -      } - -//--------------------------------------------------------- -//   getTimerTicks -//--------------------------------------------------------- - -unsigned long AlsaTimer::getTimerTicks() -      { -      snd_timer_read_t tr; -      if (snd_timer_read(handle, &tr, sizeof(tr)) == sizeof(tr)) { -            return tr.ticks; //(tr.ticks - 1) * 1024;  //?? -            } -      return 0; -      } diff --git a/muse/muse/driver/alsatimer.h b/muse/muse/driver/alsatimer.h deleted file mode 100644 index b04d9264..00000000 --- a/muse/muse/driver/alsatimer.h +++ /dev/null @@ -1,58 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Plenty of code borrowed from timer.c example in -//  alsalib 1.0.7 -// -//  (C) Copyright 2004 Robert Jonsson (rj@spamatica.se) -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __ALSATIMER_H__ -#define __ALSATIMER_H__ - -#include "alsa/asoundlib.h" -#include "timerdev.h" - -//--------------------------------------------------------- -//   AlsaTimer -//--------------------------------------------------------- - -class AlsaTimer : public Timer { -      snd_timer_t *handle; -      snd_timer_id_t *id; -      snd_timer_info_t *info; -      snd_timer_params_t *params; -      struct pollfd *fds; -      char timername[64]; -      int count; -      int ticks; - -    public: -      AlsaTimer(); -      virtual ~AlsaTimer(); - -      virtual bool initTimer(); -      virtual int  getTimerResolution(); -      virtual bool setTimerFreq(unsigned int tick); -      virtual unsigned int getTimerFreq(); -      virtual bool startTimer(); -      virtual bool stopTimer(); -      virtual unsigned long getTimerTicks(); -      virtual int getFd() const { return fds->fd; } -      }; - -#endif //__ALSATIMER_H__ diff --git a/muse/muse/driver/coremidi.cpp b/muse/muse/driver/coremidi.cpp deleted file mode 100644 index 60d164be..00000000 --- a/muse/muse/driver/coremidi.cpp +++ /dev/null @@ -1,719 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "coremidi.h" -#include "globals.h" -#include "midi.h" -#include "../midiseq.h" -#include "../song.h" -#include "al/pos.h" - -//static const unsigned int inCap  = SND_SEQ_PORT_CAP_SUBS_READ; -//static const unsigned int outCap = SND_SEQ_PORT_CAP_SUBS_WRITE; - -CoreMidi coreMidi; -CoreMidi* midiDriver; - -//--------------------------------------------------------- -//   CoreMidi -//--------------------------------------------------------- - -CoreMidi::CoreMidi() -      { -      //alsaSeq = 0; -      } - -//--------------------------------------------------------- -//   init -//    return true on error -//--------------------------------------------------------- - -bool CoreMidi::init() -      { -      if (debugMsg) -            printf("init CoreMidi\n"); -/*      int error = snd_seq_open(&alsaSeq, "hw", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK); -      if (error < 0) { -            fprintf(stderr, "open ALSA sequencer failed: %s\n", -               snd_strerror(error)); -            return true; -            } - -      snd_seq_set_client_name(alsaSeq, "MusE Sequencer"); - -      //----------------------------------------- -      //    subscribe to "Announce" -      //    this enables callbacks for any -      //    alsa port changes -      //----------------------------------------- - -      snd_seq_addr_t src, dst; -      int rv = snd_seq_create_simple_port(alsaSeq, "MusE Port 0", -         inCap | outCap | SND_SEQ_PORT_CAP_READ -         | SND_SEQ_PORT_CAP_WRITE -         | SND_SEQ_PORT_CAP_NO_EXPORT, -         SND_SEQ_PORT_TYPE_APPLICATION); -      if (rv < 0) { -            fprintf(stderr, "Alsa: create MusE port failed: %s\n", snd_strerror(error)); -            exit(1); -            } -      dst.port   = rv; -      dst.client = snd_seq_client_id(alsaSeq); -      src.port   = SND_SEQ_PORT_SYSTEM_ANNOUNCE; -      src.client = SND_SEQ_CLIENT_SYSTEM; - -      snd_seq_port_subscribe_t* subs; -      snd_seq_port_subscribe_alloca(&subs); -      snd_seq_port_subscribe_set_dest(subs, &dst); -      snd_seq_port_subscribe_set_sender(subs, &src); -      error = snd_seq_subscribe_port(alsaSeq, subs); -      if (error < 0) { -            fprintf(stderr, "Alsa: Subscribe System failed: %s\n", snd_strerror(error)); -            return true; -            } - -      return false;*/ -      return false; -      } - -//--------------------------------------------------------- -//   outputPorts -//--------------------------------------------------------- - -QList<PortName> CoreMidi::outputPorts() -      { -      QList<PortName> clientList; -/*      snd_seq_client_info_t* cinfo; -      snd_seq_client_info_alloca(&cinfo); -      snd_seq_client_info_set_client(cinfo, 0); - -      while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { -            snd_seq_port_info_t *pinfo; -            snd_seq_port_info_alloca(&pinfo); -            snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); -            snd_seq_port_info_set_port(pinfo, -1); -            while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { -                  unsigned int capability = snd_seq_port_info_get_capability(pinfo); -                  if (((capability & outCap) == outCap) -                     && !(capability & SND_SEQ_PORT_CAP_NO_EXPORT)) { -                        int client = snd_seq_port_info_get_client(pinfo); -                        if (client != snd_seq_client_id(alsaSeq)) { -                              PortName pn; -                              pn.name = QString(snd_seq_port_info_get_name(pinfo)); -                              snd_seq_addr_t* adr = new snd_seq_addr_t; -                              adr->port   = snd_seq_port_info_get_port(pinfo); -                              adr->client = client; -                              pn.port     = adr; -                              clientList.append(pn); -                              } -                        } -                  } -            }*/ -      return clientList; -      } - -//--------------------------------------------------------- -//   inputPorts -//--------------------------------------------------------- - -QList<PortName> CoreMidi::inputPorts() -      { -      QList<PortName> clientList; - -  /*    snd_seq_client_info_t* cinfo; -      snd_seq_client_info_alloca(&cinfo); -      snd_seq_client_info_set_client(cinfo, 0); - -      while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { -            snd_seq_port_info_t *pinfo; -            snd_seq_port_info_alloca(&pinfo); -            snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); -            snd_seq_port_info_set_port(pinfo, -1); -            while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { -                  unsigned int capability = snd_seq_port_info_get_capability(pinfo); -                  if (((capability & inCap) == inCap) -                     && !(capability & SND_SEQ_PORT_CAP_NO_EXPORT)) { -                        int client = snd_seq_port_info_get_client(pinfo); -                        if (client != snd_seq_client_id(alsaSeq)) { -                              PortName pn; -                              pn.name = QString(snd_seq_port_info_get_name(pinfo)); -                              snd_seq_addr_t* adr = new snd_seq_addr_t; -                              adr->port   = snd_seq_port_info_get_port(pinfo); -                              adr->client = client; -                              pn.port     = adr; -                              clientList.append(pn); -                              } -                        } -                  } -            }*/ -      return clientList; -      } - -//--------------------------------------------------------- -//   registerOutPort -//--------------------------------------------------------- - -Port CoreMidi::registerOutPort(const QString& name) -      { -//       int port  = snd_seq_create_simple_port(alsaSeq, name.toLatin1().data(), -//          outCap | SND_SEQ_PORT_CAP_WRITE, SND_SEQ_PORT_TYPE_APPLICATION); -//       if (port < 0) { -//             perror("create port"); -//             exit(1); -//             } -//       snd_seq_addr_t* adr = new snd_seq_addr_t; -//       adr->port   = port; -//       adr->client = snd_seq_client_id(alsaSeq); -//       return adr; -	return 0; -      } - -//--------------------------------------------------------- -//   equal -//--------------------------------------------------------- - -bool CoreMidi::equal(Port p1, Port p2) -      { -/*      snd_seq_addr_t* a1 = (snd_seq_addr_t*)(p1); -      snd_seq_addr_t* a2 = (snd_seq_addr_t*)(p2); -      return (a1->port == a2->port) && (a1->client == a2->client);*/ -	return false; -      } - -//--------------------------------------------------------- -//   registerInPort -//--------------------------------------------------------- - -Port CoreMidi::registerInPort(const QString& name) -      { -/*      int port  = snd_seq_create_simple_port(alsaSeq, name.toLatin1().data(), -         inCap | SND_SEQ_PORT_CAP_READ, SND_SEQ_PORT_TYPE_APPLICATION); -      if (port < 0) { -            perror("create port"); -            exit(1); -            } -      snd_seq_addr_t* adr = new snd_seq_addr_t; -      adr->port   = port; -      adr->client = snd_seq_client_id(alsaSeq); -      return adr;*/ -	return 0; -      } - -//--------------------------------------------------------- -//   unregisterPort -//--------------------------------------------------------- - -void CoreMidi::unregisterPort(Port port) -      { -/*      snd_seq_delete_simple_port(alsaSeq, AlsaPort(port)->port); -      delete (snd_seq_addr_t*)port;*/ -      } - -//--------------------------------------------------------- -//   setPortName -//--------------------------------------------------------- - -void CoreMidi::setPortName(Port, const QString& name) -      { -      printf("CoreMidi::setPortName(%s): not impl.\n", name.toLatin1().data()); -      } - -//--------------------------------------------------------- -//   portName -//--------------------------------------------------------- - -QString CoreMidi::portName(Port p) -      { -/*      snd_seq_port_info_t* pinfo; -      snd_seq_port_info_alloca(&pinfo); -      snd_seq_get_any_port_info(alsaSeq, AlsaPort(p)->client, AlsaPort(p)->port, pinfo); -      return QString(snd_seq_port_info_get_name(pinfo));*/ -	return "port"; -      } - -//--------------------------------------------------------- -//   findPort -//--------------------------------------------------------- - -Port CoreMidi::findPort(const QString& name) -      { -/*      snd_seq_addr_t* adr = new snd_seq_addr_t; -      adr->port = 0; -      adr->client = 0; - -      snd_seq_client_info_t* cinfo; -      snd_seq_client_info_alloca(&cinfo); -      snd_seq_client_info_set_client(cinfo, 0); - -      while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) { -            snd_seq_port_info_t *pinfo; -            snd_seq_port_info_alloca(&pinfo); -            snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); -            snd_seq_port_info_set_port(pinfo, -1); -            while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) { -                  const char* pn = snd_seq_port_info_get_name(pinfo); -                  if (name == pn) { -                        snd_seq_addr_t* adr = new snd_seq_addr_t; -                        *adr = *snd_seq_port_info_get_addr(pinfo); -                        return adr; -                        } -                  } -            } -      printf("CoreMidi: port <%s> not found\n", name.toLatin1().data());*/ -      return 0; -      } - -//--------------------------------------------------------- -//   connect -//    return false if connect fails -//--------------------------------------------------------- - -bool CoreMidi::connect(Port src, Port dst) -      { -/*      if (((AlsaPort)dst) == 0) { -            printf("CoreMidi::connect failed: invalid alsa port\n"); -            return false; -            } -      snd_seq_port_subscribe_t* sub; -      snd_seq_port_subscribe_alloca(&sub); - -      snd_seq_port_subscribe_set_sender(sub, (AlsaPort)src); -      snd_seq_port_subscribe_set_dest(sub, (AlsaPort)dst); -      int rv = snd_seq_subscribe_port(alsaSeq, sub); -      if (rv < 0) { -            printf("CoreMidi::connect(%d:%d, %d:%d) failed: %s\n", -               ((AlsaPort)src)->client, ((AlsaPort)src)->port, -               ((AlsaPort)dst)->client, ((AlsaPort)dst)->port, -               snd_strerror(rv)); -            return false; -            }*/ -      return true; -      } - -//--------------------------------------------------------- -//   disconnect -//    return false if disconnect fails -//--------------------------------------------------------- - -bool CoreMidi::disconnect(Port src, Port dst) -      { -/*      snd_seq_port_subscribe_t* sub; -      snd_seq_port_subscribe_alloca(&sub); -      snd_seq_port_subscribe_set_sender(sub, (AlsaPort)src); -      snd_seq_port_subscribe_set_dest(sub, (AlsaPort)dst); -      int rv = snd_seq_unsubscribe_port(alsaSeq, sub); -      if (rv < 0) -            printf("CoreMidi::disconnect() failed: %s\n", -               snd_strerror(rv)); -      return rv >= 0;*/ -	return true; -      } - -//--------------------------------------------------------- -//   getInputPollFd -//--------------------------------------------------------- - -void CoreMidi::getInputPollFd(struct pollfd** p, int* n) -      { -/*      int npfdi = snd_seq_poll_descriptors_count(alsaSeq, POLLIN); -      struct pollfd* pfdi  = new struct pollfd[npfdi]; -      snd_seq_poll_descriptors(alsaSeq, pfdi, npfdi, POLLIN); -      *p = pfdi; -      *n = npfdi;*/ -      *n=0; -      } - -//--------------------------------------------------------- -//   getOutputPollFd -//--------------------------------------------------------- - -void CoreMidi::getOutputPollFd(struct pollfd** p, int* n) -      { -/*      int npfdo = snd_seq_poll_descriptors_count(alsaSeq, POLLOUT); -      struct pollfd* pfdo  = new struct pollfd[npfdo]; -      snd_seq_poll_descriptors(alsaSeq, pfdo, npfdo, POLLOUT); -      *p = pfdo; -      *n = npfdo;*/ -      n=0; -      } - -//--------------------------------------------------------- -//   addConnection -//    a new connection was added -//--------------------------------------------------------- - -/*void CoreMidi::addConnection(snd_seq_connect_t* ev) -      { -      Port rs = Port(&ev->sender); -      Port rd = Port(&ev->dest); - -      MidiOutPortList* opl = song->midiOutPorts(); -      for (iMidiOutPort i = opl->begin(); i != opl->end(); ++i) { -            MidiOutPort* oport = *i; -            Port src = oport->port(); - -            if (equal(src, rs)) { -                  RouteList* orl = oport->outRoutes(); -                  iRoute ir; -                  for (ir = orl->begin(); ir != orl->end(); ++ir) { -                        Port dst = ir->port; -                        if (equal(dst, rd)) -                              break; -                        } -                  if (ir == orl->end()) { -                        snd_seq_addr_t* adr = new snd_seq_addr_t(ev->dest); -                        orl->push_back(Route(Port(adr), Route::MIDIPORT)); -                        } -                  break; -                  } -            } - -      MidiInPortList* ipl = song->midiInPorts(); -      for (iMidiInPort i = ipl->begin(); i != ipl->end(); ++i) { -            MidiInPort* iport = *i; -            Port dst = iport->port(); - -            if (equal(dst, rd)) { -                  RouteList* irl = iport->inRoutes(); -                  iRoute ir; -                  for (ir = irl->begin(); ir != irl->end(); ++ir) { -                        Port src = ir->port; -                        if (equal(src, rs)) -                              break; -                        } -                  if (ir == irl->end()) { -                        snd_seq_addr_t* adr = new snd_seq_addr_t(ev->sender); -                        irl->push_back(Route(Port(adr), Route::MIDIPORT)); -                        } -                  break; -                  } -            } -      } -*/ -//--------------------------------------------------------- -//   removeConnection -//    a connection was removed -//--------------------------------------------------------- -/* -void CoreMidi::removeConnection(snd_seq_connect_t* ev) -      { -      Port rs = Port(&ev->sender); -      Port rd = Port(&ev->dest); - -      MidiInPortList* ipl = song->midiInPorts(); -      for (iMidiInPort i = ipl->begin(); i != ipl->end(); ++i) { -            MidiInPort* iport = *i; -            Port dst = iport->port(); - -            if (equal(dst, rd)) { -                  RouteList* irl = iport->inRoutes(); -                  for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) { -                        Port src = ir->port; - -                        if (equal(src, rs)) { -                              irl->erase(ir); -                              break; -                              } -                        } -                  break; -                  } -            } - -      MidiOutPortList* opl = song->midiOutPorts(); -      for (iMidiOutPort i = opl->begin(); i != opl->end(); ++i) { -            MidiOutPort* oport = *i; -            Port src = oport->port(); - -            if (equal(src, rs)) { -                  RouteList* orl = oport->outRoutes(); -                  for (iRoute r = orl->begin(); r != orl->end(); ++r) { -                        Port dst = r->port; - -                        if (equal(dst, rd)) { -                              orl->erase(r); -printf("REMOVE OUT connection\n"); -                              break; -                              } -                        } -                  break; -                  } -            } -      } -*/ -//--------------------------------------------------------- -//   read -//    read ALSA midi events -//    This is called by the high priority RT MidiSeq -//    thread. -//--------------------------------------------------------- - -void CoreMidi::read(MidiSeq* seq) -      { -/*      snd_seq_event_t* ev; -      for (int i = 0;; ++i) { -            int rv = snd_seq_event_input(alsaSeq, &ev); -            if (rv <= 0) { -                  if (rv < 0 && rv != -11)   // Resource temporarily unavailable -                        printf("CoreMidi: read error 0x%x %s\n", rv, snd_strerror(rv)); -                  break; -                  } -// printf("Alsa midi event %d %d\n", rv, ev->type); - -            switch(ev->type) { -                  case SND_SEQ_EVENT_PORT_SUBSCRIBED: -                        // printf("subscribe\n"); -                        addConnection((snd_seq_connect_t*)(&ev->data)); -                        break; -                  case SND_SEQ_EVENT_PORT_UNSUBSCRIBED: -                        // printf("unsubscribe\n"); -                        removeConnection((snd_seq_connect_t*)(&ev->data)); -                        break; -                  case SND_SEQ_EVENT_CLIENT_START: -                        // printf("client start\n"); -                        break; -                  case SND_SEQ_EVENT_CLIENT_EXIT: -                        // printf("client exit\n"); -                        break; -                  case SND_SEQ_EVENT_PORT_START: -                        // printf("port start\n"); -                        break; -                  case SND_SEQ_EVENT_PORT_EXIT: -                        // printf("port exit\n"); -                        break; -                  case SND_SEQ_EVENT_SYSEX: -                  	{ -                        // -                        // look for Midi Machine Control events (MMC) -                        // -                        unsigned char* data = ((unsigned char*)ev->data.ext.ptr) + 1; -                        int len = ev->data.ext.len - 2; -                        if ((len == 4) && (data[0] == 0x7f) && (data[2] == 0x06)) { -                              seq->mmcInput(data[1], data[3], 0); -                              break; -                              } -                        if ((len == 11) && (data[0] == 0x7f) -                           && (data[2] == 0x06) -                           && (data[3] == 0x44) && (data[4] == 0x06) -                           && (data[5] == 0x1)) { -                              int h = data[6]; -                              int m = data[7]; -                              int s = data[8]; -                              int f = data[9]; -                              int sf = data[10]; -                              AL::Pos pos(h * 60 + m, s, f, sf); -                              seq->mmcInput(data[1], data[3], pos); -                              break; -                              } -                        } -                  	 -                  case SND_SEQ_EVENT_KEYPRESS: -                  case SND_SEQ_EVENT_CHANPRESS: -                  case SND_SEQ_EVENT_NOTEON: -                  case SND_SEQ_EVENT_NOTEOFF: -                  case SND_SEQ_EVENT_PGMCHANGE: -                  case SND_SEQ_EVENT_PITCHBEND: -                  case SND_SEQ_EVENT_CONTROLLER: -                        { -                        Port port = &ev->dest; -                        MidiInPortList* mpl = song->midiInPorts(); -                        for (iMidiInPort i = mpl->begin(); i != mpl->end(); ++i) { -                              MidiInPort* inPort = *i; -                              if (equal(port, inPort->port())) { -                                    inPort->eventReceived(ev); -                                    } -                              } -                        } -                        break; - -                  case SND_SEQ_EVENT_CLOCK: -                        seq->realtimeSystemInput(0, 0xf8); -                        break; -                  case SND_SEQ_EVENT_START: -                        seq->realtimeSystemInput(0, 0xfa); -                        break; -                  case SND_SEQ_EVENT_CONTINUE: -                        seq->realtimeSystemInput(0, 0xfb); -                        break; -                  case SND_SEQ_EVENT_STOP: -                        seq->realtimeSystemInput(0, 0xfc); -                        break; -                  case SND_SEQ_EVENT_TICK: -                        seq->realtimeSystemInput(0, 0xf9); -                        break; -                  case SND_SEQ_EVENT_SONGPOS: -                        seq->setSongPosition(0, ev->data.control.value); -                        break; -                  case SND_SEQ_EVENT_SENSING: -                        break; -                  case SND_SEQ_EVENT_QFRAME: -                        seq->mtcInputQuarter(0, ev->data.control.value); -                        break; -                  // case SND_SEQ_EVENT_CLIENT_START: -                  // case SND_SEQ_EVENT_CLIENT_EXIT: -                  // case SND_SEQ_EVENT_CLIENT_CHANGE: -                  // case SND_SEQ_EVENT_PORT_CHANGE: -                  // case SND_SEQ_EVENT_SONGSEL: -                  // case SND_SEQ_EVENT_TIMESIGN: -                  // case SND_SEQ_EVENT_KEYSIGN: -                  // case SND_SEQ_EVENT_SETPOS_TICK: -                  // case SND_SEQ_EVENT_SETPOS_TIME: -                  // case SND_SEQ_EVENT_TEMPO: -                  // case SND_SEQ_EVENT_TUNE_REQUEST: -                  // case SND_SEQ_EVENT_RESET: -                  // case SND_SEQ_EVENT_NOTE: -                  // case SND_SEQ_EVENT_CONTROL14: -                  // case SND_SEQ_EVENT_NONREGPARAM: -                  // case SND_SEQ_EVENT_REGPARAM: -                  default: -                        printf("ALSA Midi input: type %d not handled\n", ev->type); -                        break; -                  } -            snd_seq_free_event(ev); -            }*/ -      } - -//--------------------------------------------------------- -//   write -//--------------------------------------------------------- - -void CoreMidi::write() -      { -      } - -//--------------------------------------------------------- -//   putEvent -//--------------------------------------------------------- - -void CoreMidi::putEvent(Port p, const MidiEvent& e) -      { -/*      if (midiOutputTrace) { -            printf("MidiOut<%s>: midiAlsa: ", portName(p).toLatin1().data()); -            e.dump(); -            } -      int chn = e.channel(); -      int a   = e.dataA(); -      int b   = e.dataB(); - -      snd_seq_event_t event; -      memset(&event, 0, sizeof(event)); -      snd_seq_ev_set_direct(&event); -      snd_seq_ev_set_source(&event, ((snd_seq_addr_t*)p)->port); -      snd_seq_ev_set_dest(&event, SND_SEQ_ADDRESS_SUBSCRIBERS, 0); - -      switch(e.type()) { -            case ME_NOTEON: -                  snd_seq_ev_set_noteon(&event, chn, a, b); -                  break; -            case ME_NOTEOFF: -                  snd_seq_ev_set_noteoff(&event, chn, a, 0); -                  break; -            case ME_PROGRAM: -                  snd_seq_ev_set_pgmchange(&event, chn, a); -                  break; -            case ME_CONTROLLER: -                  snd_seq_ev_set_controller(&event, chn, a, b); -                  break; -            case ME_PITCHBEND: -                  snd_seq_ev_set_pitchbend(&event, chn, a); -                  break; -            case ME_POLYAFTER: -                  // chnEvent2(chn, 0xa0, a, b); -                  break; -            case ME_AFTERTOUCH: -                  snd_seq_ev_set_chanpress(&event, chn, a); -                  break; -            case ME_SYSEX: -                  { -                  const unsigned char* p = e.data(); -                  int n                  = e.len(); -                  int len                = n + sizeof(event) + 2; -                  char buf[len]; -                  event.type             = SND_SEQ_EVENT_SYSEX; -                  event.flags            = SND_SEQ_EVENT_LENGTH_VARIABLE; -                  event.data.ext.len     = n + 2; -                  event.data.ext.ptr  = (void*)(buf + sizeof(event)); -                  memcpy(buf, &event, sizeof(event)); -                  char* pp = buf + sizeof(event); -                  *pp++ = 0xf0; -                  memcpy(pp, p, n); -                  pp += n; -                  *pp = 0xf7; -                  putEvent(&event); -                  return; -                  } -            case ME_SONGPOS: -                  event.data.control.value = a; -                  event.type = SND_SEQ_EVENT_SONGPOS; -                  break; -            case ME_CLOCK: -                  event.type = SND_SEQ_EVENT_CLOCK; -                  break; -            case ME_START: -                  event.type = SND_SEQ_EVENT_START; -                  break; -            case ME_CONTINUE: -                  event.type = SND_SEQ_EVENT_CONTINUE; -                  break; -            case ME_STOP: -                  event.type = SND_SEQ_EVENT_STOP; -                  break; -            default: -                  printf("MidiAlsaDevice::putEvent(): event type %d not implemented\n", -                     e.type()); -                  return; -            } -      putEvent(&event);*/ -      } - -//--------------------------------------------------------- -//   putEvent -//    return false if event is delivered -//--------------------------------------------------------- - -// bool CoreMidi::putEvent(snd_seq_event_t* event) -//       { -//       int error; -//  -//       do { -//             error   = snd_seq_event_output_direct(alsaSeq, event); -//             int len = snd_seq_event_length(event); -//             if (error == len) { -// //                  printf(".");fflush(stdout); -//                   return false; -//                   } -//             if (error < 0) { -//                   if (error == -12) { -// //                        printf("?");fflush(stdout); -//                         return true; -//                         } -//                   else { -//                         fprintf(stderr, "MidiAlsaDevice::%p putEvent(): midi write error: %s\n", -//                            this, snd_strerror(error)); -//                         //exit(-1); -//                         } -//                   } -//             else -//                   fprintf(stderr, "MidiAlsaDevice::putEvent(): midi write returns %d, expected %d: %s\n", -//                      error, len, snd_strerror(error)); -//             } while (error == -12); -//       return true; -//       } - - diff --git a/muse/muse/driver/coremidi.h b/muse/muse/driver/coremidi.h deleted file mode 100644 index 28e79ca7..00000000 --- a/muse/muse/driver/coremidi.h +++ /dev/null @@ -1,72 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __COREMIDI_H__ -#define __COREMIDI_H__ - -#include "driver.h" - -class MidiSeq; -class MidiEvent; - -//typedef snd_seq_addr_t* AlsaPort; - -//--------------------------------------------------------- -//   CoreMidi -//--------------------------------------------------------- - -class CoreMidi : public Driver { -      //snd_seq_t* alsaSeq; - -//       void removeConnection(snd_seq_connect_t* ev); -//       void addConnection(snd_seq_connect_t* ev); - -   public: -      CoreMidi(); -      virtual bool init(); - -      virtual QList<PortName> outputPorts(); -      virtual QList<PortName> inputPorts(); - -      virtual Port registerOutPort(const QString& name); -      virtual Port registerInPort(const QString& name); -      virtual void unregisterPort(Port); -      virtual void setPortName(Port p, const QString& n); -      virtual QString portName(Port); -      virtual Port findPort(const QString& name); -      virtual bool equal(Port, Port); - -      virtual bool connect(Port, Port); -      virtual bool disconnect(Port, Port); - -      void getInputPollFd(struct pollfd**, int* n); -      void getOutputPollFd(struct pollfd**, int* n); - -      void read(MidiSeq*);      // process events -      void write(); - -      void putEvent(Port, const MidiEvent&); -      //bool putEvent(snd_seq_event_t* event); -      }; - -extern CoreMidi coreMidi; -extern CoreMidi* midiDriver; -#endif - diff --git a/muse/muse/driver/coretimer.cpp b/muse/muse/driver/coretimer.cpp deleted file mode 100644 index 627960d5..00000000 --- a/muse/muse/driver/coretimer.cpp +++ /dev/null @@ -1,156 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  (C) Copyright 2004 Robert Jonsson (rj@spamatica.se) -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "coretimer.h" -#include "globals.h" -#include "gconfig.h" - - -CoreTimer::CoreTimer() -    { -    timerFd = -1; -    } - -CoreTimer::~CoreTimer() -    { -    if (timerFd != -1) -      close(timerFd); -    } - -bool CoreTimer::initTimer() -    { -    if(TIMER_DEBUG) -          printf("CoreTimer::initTimer()\n"); -/*    if (timerFd != -1) { -          fprintf(stderr,"CoreTimer::initTimer(): called on initialised timer!\n"); -          return -1; -    } -    doSetuid(); - -    timerFd = ::open("/dev/rtc", O_RDONLY); -    if (timerFd == -1) { -          fprintf(stderr, "fatal error: open /dev/rtc failed: %s\n", strerror(errno)); -          undoSetuid(); -          return timerFd; -          } -    if (!setTimerFreq(config.rtcTicks)) { -          // unable to set timer frequency -          return -1; -          } -    // check if timer really works, start and stop it once. -    if (!startTimer()) { -          return -1; -          } -    if (!stopTimer()) { -          return -1; -          } -*/ -    return true; -    } - -unsigned int CoreTimer::setTimerResolution(unsigned int resolution) -    { -    if(TIMER_DEBUG) -      printf("CoreTimer::setTimerResolution(%d)\n",resolution); -    /* The RTC can take power-of-two frequencies from 2 to 8196 Hz. -     * It doesn't really have a resolution as such. -     */ -    return 0; -    } - -bool CoreTimer::setTimerFreq(unsigned int freq) -    { -/*    int rc = ioctl(timerFd, RTC_IRQP_SET, freq); -    if (rc == -1) { -            fprintf(stderr, "CoreTimer::setTimerFreq(): cannot set tick on /dev/rtc: %s\n", -               strerror(errno)); -            fprintf(stderr, "  precise timer not available\n"); -            return 0; -            } -*/ -    return true ; -    } - -int CoreTimer::getTimerResolution() -    { -    /* The RTC doesn't really work with a set resolution as such. -     * Not sure how this fits into things yet. -     */ -    return 0; -    } - -unsigned int CoreTimer::getTimerFreq() -    { -    unsigned int freq; -/*    int rv = ioctl(timerFd, RTC_IRQP_READ, &freq); -    if (rv < 1) -      return 0; -*/ -    return freq; -    } - -bool CoreTimer::startTimer() -    { -    if(TIMER_DEBUG) -      printf("CoreTimer::startTimer()\n"); -/*    if (timerFd == -1) { -          fprintf(stderr, "CoreTimer::startTimer(): no timer open to start!\n"); -          return false; -          } -    if (ioctl(timerFd, RTC_PIE_ON, 0) == -1) { -        perror("MidiThread: start: RTC_PIE_ON failed"); -        undoSetuid(); -        return false; -        } -*/    return true; -    } - -bool CoreTimer::stopTimer() -    { -/*    if(TIMER_DEBUG) -      printf("CoreTimer::stopTimer\n"); -    if (timerFd != -1) { -        ioctl(timerFd, RTC_PIE_OFF, 0); -        } -    else { -        fprintf(stderr,"CoreTimer::stopTimer(): no RTC to stop!\n"); -        return false; -        } -*/    return true; -    } - -unsigned long CoreTimer::getTimerTicks() -    { -    if(TIMER_DEBUG) -      printf("getTimerTicks()\n"); -    unsigned long int nn; -/*    if (timerFd==-1) { -        fprintf(stderr,"CoreTimer::getTimerTicks(): no RTC open to read!\n"); -        return 0; -    } -    if (read(timerFd, &nn, sizeof(unsigned long)) != sizeof(unsigned long)) { -        fprintf(stderr,"CoreTimer::getTimerTicks(): error reading RTC\n"); -        return 0; -        } -*/ -    return nn; -    } - diff --git a/muse/muse/driver/coretimer.h b/muse/muse/driver/coretimer.h deleted file mode 100644 index a6342098..00000000 --- a/muse/muse/driver/coretimer.h +++ /dev/null @@ -1,53 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  (C) Copyright 2004-2006 Robert Jonsson (rj@spamatica.se) -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __CORETIMER_H__ -#define __CORETIMER_H__ - -#include "timerdev.h" - -//--------------------------------------------------------- -//   AlsaTimer -//--------------------------------------------------------- - -class CoreTimer : public Timer { -     - -    public: -       CoreTimer(); -       virtual ~CoreTimer(); -        -       virtual bool initTimer(); -       virtual unsigned int setTimerResolution(unsigned int resolution); -       virtual int getTimerResolution(); -       virtual bool setTimerFreq(unsigned int tick); -       virtual unsigned int getTimerFreq(); - -       virtual bool startTimer(); -       virtual bool stopTimer(); -       virtual unsigned long getTimerTicks(); -       -    private: -      int timerFd;  - -}; - -#endif //__CORETIMER_H__ diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp index 34a92dfe..cde57418 100644 --- a/muse/muse/driver/jack.cpp +++ b/muse/muse/driver/jack.cpp @@ -220,7 +220,6 @@ static void noJackError(const char* /* s */)  JackAudio::JackAudio(jack_client_t* cl, char* name)     : AudioDriver()        { -printf("JackAudio::JackAudio(%p,%s)\n", cl, name);        strcpy(jackRegisteredName, name);        _client = cl;        } @@ -237,7 +236,6 @@ JackAudio::~JackAudio()                       strerror(errno));                    }              } -printf("JackAudio::~JackAudio\n");        _client = 0;        } @@ -256,7 +254,7 @@ char* JackAudio::getJackName()  bool JackAudio::restart()        { -printf("JackAudio::restart\n"); +      printf("JackAudio::restart\n");        _client = jack_client_new(jackRegisteredName);        if (!_client)              return true; diff --git a/muse/muse/driver/mididev.h b/muse/muse/driver/mididev.h deleted file mode 100644 index 0d52e2d3..00000000 --- a/muse/muse/driver/mididev.h +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  (C) Copyright 2006 Robert Jonsson rj at spamatica.se -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __MIDIDEV_H__ -#define __MIDIDEV_H__ - -#ifdef __APPLE__ -#include "driver/coremidi.h" -#else -#include "driver/alsamidi.h" -#endif - - -#endif - diff --git a/muse/muse/driver/posixtimer.cpp b/muse/muse/driver/posixtimer.cpp deleted file mode 100644 index c5622bb3..00000000 --- a/muse/muse/driver/posixtimer.cpp +++ /dev/null @@ -1,191 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -// -// support posix high resolution timers -//    http://sourceforge.net/projects/high-res-timers -// -#include <signal.h> -#include <memory.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include "posixtimer.h" - -extern bool debugMsg; - -static int fd[2]; - -//--------------------------------------------------------- -//   getFd -//--------------------------------------------------------- - -int PosixTimer::getFd() const -      { -      return fd[0]; -      } - -//--------------------------------------------------------- -//   sigalarm -//--------------------------------------------------------- - -static void sigalarm(int /*signo*/) -      { -      write(fd[1], ".", 1); -      } - -//--------------------------------------------------------- -//   PosixTimer -//--------------------------------------------------------- - -PosixTimer::PosixTimer() -      { -      timerId = 0; -      } - -PosixTimer::~PosixTimer() -      { -      if (timerId != 0) -            timer_delete(timerId); -      } - -//--------------------------------------------------------- -//   initTimer -//    return -1 on error -//--------------------------------------------------------- - -bool PosixTimer::initTimer() -      { -      pthread_t tid = pthread_self(); -printf("tid %p\n", (void*)tid); -      struct sigevent se; -      memset(&se, 0, sizeof(se)); -      se.sigev_notify = SIGEV_THREAD_ID; -      se.sigev_signo  = SIGRTMAX; -//      se.sigev_value.sival_ptr = this; -      se._sigev_un._tid = tid; - -      // allocate timer -      int rv; -      clock = CLOCK_REALTIME; -      rv = timer_create(clock, &se, &timerId); - -      if (rv < 0) { -            perror("posix timer create"); -            fprintf(stderr, "no posix timer available\n"); -            return false; -            } -      else if (debugMsg) { -            if (clock == CLOCK_REALTIME) -                  printf("created CLOCK_REALTIME posix timer\n"); -            } - -      // Set up signal handler: - -      struct sigaction act; -      sigfillset(&act.sa_mask); -      act.sa_flags = 0; -      act.sa_handler = sigalarm; -      sigaction(SIGRTMAX, &act, 0); - -      if (pipe(fd) < 0) { -            perror("PosixTimer::initTimer: create pipe"); -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   getTimerResolution -//    return timer resolution in microseconds -//--------------------------------------------------------- - -int PosixTimer::getTimerResolution() -      { -      struct timespec spec; -      int rv = clock_getres(clock, &spec); -      if (rv != -1) -            return spec.tv_nsec / 1000; -      return 0; -      } - -//--------------------------------------------------------- -//   setTimerTicks -//    return false on error -//--------------------------------------------------------- - -bool PosixTimer::setTimerTicks(int tick) -      { -      double nsec = (1000.0*1000.0*1000.0) / tick; -      ts.it_interval.tv_sec  = 0; -      ts.it_interval.tv_nsec = int(nsec); -      ts.it_value = ts.it_interval; -      return true; -      } - -//--------------------------------------------------------- -//   startTimer -//--------------------------------------------------------- - -bool PosixTimer::startTimer() -      { -      int rv = timer_settime(timerId, 0, &ts, 0); -      if (rv < 0) { -            perror("PosixTimer::startTimer: timer_settime"); -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   stopTimer -//--------------------------------------------------------- - -bool PosixTimer::stopTimer() -      { -      struct itimerspec s; -      s.it_interval.tv_sec  = 0; -      s.it_interval.tv_nsec = 0; -      s.it_value.tv_sec = 0; -      s.it_value.tv_nsec = 0; - -      int rv = timer_settime(timerId, 0, &s, 0); -      if (rv < 0) { -            perror("PosixTimer::stopTimer: timer_settime"); -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   getTimerTicks -//--------------------------------------------------------- - -unsigned long PosixTimer::getTimerTicks() -      { -      char buffer[16]; -      int n = read(fd[0], buffer, 16); -if (n != 1) -      printf("getTimerTicks %d\n", n); -      return n; -//      int n = timer_getoverrun(timerId); -//      return n; -      } - diff --git a/muse/muse/driver/posixtimer.h b/muse/muse/driver/posixtimer.h deleted file mode 100644 index c68945b2..00000000 --- a/muse/muse/driver/posixtimer.h +++ /dev/null @@ -1,51 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __POSIXTIMER_H__ -#define __POSIXTIMER_H__ - -#include <time.h> -#include "timerdev.h" - -//--------------------------------------------------------- -//   PosixTimer -//--------------------------------------------------------- - -class PosixTimer : public Timer{ -      timer_t timerId; -      struct itimerspec ts; -      clock_t clock; - -    public: -      PosixTimer(); -      virtual ~PosixTimer(); - -      virtual bool initTimer(); -      virtual int  getTimerResolution(); -      virtual bool setTimerTicks(int tick); - -      virtual bool startTimer(); -      virtual bool stopTimer(); -      virtual unsigned long  getTimerTicks(); -      virtual int getFd() const; -      }; - -#endif //__POSIXTIMER_H__ - diff --git a/muse/muse/driver/rtctimer.cpp b/muse/muse/driver/rtctimer.cpp deleted file mode 100644 index d683f4c6..00000000 --- a/muse/muse/driver/rtctimer.cpp +++ /dev/null @@ -1,200 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  (C) Copyright 2004 Robert Jonsson (rj@spamatica.se) -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include <linux/version.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) -#include <linux/spinlock.h> -#include <linux/mc146818rtc.h> -#else -#include <linux/rtc.h> -#endif -#include <stdio.h> -#include <fcntl.h> -#include <sys/ioctl.h> -#include <poll.h> - - -#include "rtctimer.h" -#include "globals.h" -#include "gconfig.h" -#include "widgets/utils.h" - - -//--------------------------------------------------------- -//   RtcTimer -//--------------------------------------------------------- - -RtcTimer::RtcTimer() -      { -      timerFd = -1; -      } - -//--------------------------------------------------------- -//   ~RtcTimer -//--------------------------------------------------------- -RtcTimer::~RtcTimer() -    { -    if (timerFd != -1) -      close(timerFd); -    } - -//--------------------------------------------------------- -//   initTimer -//    return false on error -//--------------------------------------------------------- - -bool RtcTimer::initTimer() -      { -      if(TIMER_DEBUG) -            printf("RtcTimer::initTimer()\n"); -      if (timerFd != -1) { -            fprintf(stderr,"RtcTimer::initTimer(): called on initialised timer!\n"); -            return false; -            } -      timerFd = ::open("/dev/rtc", O_RDONLY); -      if (timerFd == -1) { -            fprintf(stderr, "RtcTimer:: fatal error: open /dev/rtc failed: %s\n", -               strerror(errno)); -            return false; -            } -      if (!setTimerFreq(config.rtcTicks)) { -            // unable to set timer frequency -            timerFd = -1; -            return false; -            } -      // check if timer really works, start and stop it once. -      if (!startTimer()) { -            timerFd = -1; -            return false; -            } -      if (!stopTimer()) { -            timerFd = -1; -            return false; -            } -      // stop has closed the device, open it again -      timerFd = ::open("/dev/rtc", O_RDONLY); -      return true;       -      } - - -//--------------------------------------------------------- -//   setTimerFreq -//    return false on error -//--------------------------------------------------------- - -bool RtcTimer::setTimerFreq(unsigned int tick) -    { -    int rc = ioctl(timerFd, RTC_IRQP_SET, tick); -    if (rc == -1) { -            fprintf(stderr, "RtcTimer::setTimerFreq(): cannot set ticks %d on /dev/rtc: %s\n", -               config.rtcTicks, strerror(errno)); -            fprintf(stderr, "  precise timer not available\n"); -            close(timerFd); -            //if (!debugMode) -            //      fatalError("set timer ticks failed"); -            timerFd = -1; -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   getTimerResolution -//--------------------------------------------------------- - -int RtcTimer::getTimerResolution() -      { -      /* The RTC doesn't really work with a set resolution as such. -       * Not sure how this fits into things yet. -       */ -      return 0; -      } - -//--------------------------------------------------------- -//   getTimerFreq -//--------------------------------------------------------- - -unsigned int RtcTimer::getTimerFreq() -    { -    unsigned int freq; -    int rv = ioctl(timerFd, RTC_IRQP_READ, &freq); -    if (rv < 1) -      return 0; -    return freq; -    } -//--------------------------------------------------------- -//   startTimer -//--------------------------------------------------------- - -bool RtcTimer::startTimer() -      { -      if (TIMER_DEBUG) -            printf("RtcTimer::startTimer\n"); -      if (timerFd == -1) { -            if (!debugMode) -                  fprintf(stderr, "RtcTimer::startTimer(): no timer to start.\n"); -            return false; -            } -      if (ioctl(timerFd, RTC_PIE_ON, 0) == -1) { -            perror("RtcTimer::startTimer(): start: RTC_PIE_ON failed"); -            ::close(timerFd); -            timerFd = -1; -            return false; -            } -      return true; -      } - -//--------------------------------------------------------- -//   stopTimer -//--------------------------------------------------------- - -bool RtcTimer::stopTimer() -      { -      if (TIMER_DEBUG) -            printf("RtcTimer::stopTimer\n"); -      if (timerFd != -1) { -          ioctl(timerFd, RTC_PIE_OFF, 0); -          ::close(timerFd); -          timerFd = -1; -          } -      return true; -      } - -//--------------------------------------------------------- -//   getTimerTicks -//--------------------------------------------------------- - -unsigned long RtcTimer::getTimerTicks() -      { -      if (TIMER_DEBUG) -            printf("getTimerTicks()\n"); -      if (timerFd==-1) { -          fprintf(stderr,"RtcTimer::getTimerTicks(): no RTC open to read!\n"); -          return 0; -      } -      unsigned long nn; -      if (read(timerFd, &nn, sizeof(unsigned long)) != sizeof(unsigned long)) { -            perror("rtc timer read error"); -            fatalError("RtcTimer::getTimerTicks(): error reading RTC"); -            } -      return nn; -      } - diff --git a/muse/muse/driver/rtctimer.h b/muse/muse/driver/rtctimer.h deleted file mode 100644 index ca4532df..00000000 --- a/muse/muse/driver/rtctimer.h +++ /dev/null @@ -1,49 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  (C) Copyright 2004 Robert Jonsson (rj@spamatica.se) -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __RTCTIMER_H__ -#define __RTCTIMER_H__ - -#include "timerdev.h" - -//--------------------------------------------------------- -//   RtcTimer -//--------------------------------------------------------- - -class RtcTimer : public Timer{ -      int timerFd; - -    public: -      RtcTimer(); -      virtual ~RtcTimer(); - -      virtual bool initTimer(); -      virtual int getTimerResolution(); -      virtual bool setTimerFreq(unsigned int tick); -      virtual unsigned int getTimerFreq(); - -      virtual bool startTimer(); -      virtual bool stopTimer(); -      virtual unsigned long  getTimerTicks(); -      virtual int getFd() const { return timerFd; } -      }; - -#endif //__ALSATIMER_H__ diff --git a/muse/muse/driver/timerdev.h b/muse/muse/driver/timerdev.h deleted file mode 100644 index 923d39a3..00000000 --- a/muse/muse/driver/timerdev.h +++ /dev/null @@ -1,51 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Plenty of code borrowed from timer.c example in -//  alsalib 1.0.7 -// -//  (C) Copyright 2004 Robert Jonsson (rj@spamatica.se) -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __TIMERDEV_H__ -#define __TIMERDEV_H__ - -#include <pthread.h> - -#define TIMER_DEBUG 0 - -//--------------------------------------------------------- -//   Timer -//--------------------------------------------------------- - -class Timer { - -     public: -      Timer() {}; -      virtual ~Timer() {}; - -      virtual bool initTimer() = 0; -      virtual int  getTimerResolution() = 0; -      virtual bool setTimerFreq(unsigned int freq) = 0; - -      virtual bool startTimer() = 0; -      virtual bool stopTimer() = 0; -      virtual unsigned long getTimerTicks() = 0; -      virtual int getFd() const { return -1; } -      }; - -#endif //__TIMERDEV_H__ diff --git a/muse/muse/fifo.cpp b/muse/muse/fifo.cpp index 32300f92..12c2febf 100644 --- a/muse/muse/fifo.cpp +++ b/muse/muse/fifo.cpp @@ -40,7 +40,8 @@ void FifoBase::clear()  void FifoBase::push()        {        widx = (widx + 1) % FIFO_BUFFER; -      q_atomic_increment(&counter); +//      q_atomic_increment(&counter); +      ++counter;        }  //--------------------------------------------------------- @@ -50,7 +51,8 @@ void FifoBase::push()  void FifoBase::pop()        {        ridx = (ridx + 1) % FIFO_BUFFER; -      q_atomic_decrement(&counter); +      // q_atomic_decrement(&counter); +      --counter;        }  //--------------------------------------------------------- diff --git a/muse/muse/globals.cpp b/muse/muse/globals.cpp index e919b933..86871a0c 100644 --- a/muse/muse/globals.cpp +++ b/muse/muse/globals.cpp @@ -130,5 +130,4 @@ QAction* recordAction;  QAction* panicAction;  bool rcEnable = false; -bool midiSeqRunning = false; diff --git a/muse/muse/importmidi.cpp b/muse/muse/importmidi.cpp index db8179dd..8f27e2d7 100644 --- a/muse/muse/importmidi.cpp +++ b/muse/muse/importmidi.cpp @@ -30,7 +30,6 @@  #include "al/tempo.h"  #include "instruments/minstrument.h"  #include "gconfig.h" -#include "driver/mididev.h"  #include "part.h"  #include "importmidi.h"  #include "projectdialog.h" @@ -315,15 +314,6 @@ void MusE::addMidiFile(const QString name)              outPort->setDefaultName();              song->insertTrack0(outPort, -1); -#if 0 -            // -            // route output to preferred midi device -            // -            if (!config.defaultMidiOutputDevice.isEmpty()) { -                  Route dst(config.defaultMidiOutputDevice, 0, Route::MIDIPORT); -                  outPort->outRoutes()->push_back(dst); -                  } -#endif              //              // set preferred instrument              // diff --git a/muse/muse/midi.cpp b/muse/muse/midi.cpp index b93bf1c9..122055a6 100644 --- a/muse/muse/midi.cpp +++ b/muse/muse/midi.cpp @@ -26,12 +26,10 @@  #include "midictrl.h"  #include "midictrl.h"  #include "audio.h" -#include "driver/mididev.h"  #include "driver/audiodev.h"  #include "wave.h"  #include "synth.h"  #include "sync.h" -#include "midiseq.h"  #include "gconfig.h"  #include "ticksynth.h"  #include "al/tempo.h" diff --git a/muse/muse/midififo.cpp b/muse/muse/midififo.cpp index cf244301..f68afd83 100644 --- a/muse/muse/midififo.cpp +++ b/muse/muse/midififo.cpp @@ -30,7 +30,8 @@ bool MidiFifo::put(const MidiEvent& event)        if (size < MIDI_FIFO_SIZE) {              fifo[wIndex] = event;              wIndex = (wIndex + 1) % MIDI_FIFO_SIZE; -            q_atomic_increment(&size); +            // q_atomic_increment(&size); +            ++size;              return false;              }        return true; @@ -44,7 +45,8 @@ MidiEvent MidiFifo::get()        {        MidiEvent event(fifo[rIndex]);        rIndex = (rIndex + 1) % MIDI_FIFO_SIZE; -      q_atomic_decrement(&size); +      // q_atomic_decrement(&size); +      --size;        return event;        } @@ -65,7 +67,8 @@ const MidiEvent& MidiFifo::peek(int n)  void MidiFifo::remove()        {        rIndex = (rIndex + 1) % MIDI_FIFO_SIZE; -      q_atomic_decrement(&size); +      // q_atomic_decrement(&size); +      --size;        }  //--------------------------------------------------------- @@ -78,7 +81,8 @@ bool MidiOutFifo::put(const MidiOutEvent& event)        if (size < MIDI_FIFO_SIZE) {              fifo[wIndex] = event;              wIndex = (wIndex + 1) % MIDI_FIFO_SIZE; -            q_atomic_increment(&size); +            // q_atomic_increment(&size); +            ++size;              return false;              }        return true; @@ -92,7 +96,8 @@ MidiOutEvent MidiOutFifo::get()        {        MidiOutEvent event(fifo[rIndex]);        rIndex = (rIndex + 1) % MIDI_FIFO_SIZE; -      q_atomic_decrement(&size); +      // q_atomic_decrement(&size); +      --size;        return event;        } diff --git a/muse/muse/midiinport.cpp b/muse/muse/midiinport.cpp index 81f88a1e..22671375 100644 --- a/muse/muse/midiinport.cpp +++ b/muse/muse/midiinport.cpp @@ -23,7 +23,6 @@  #include "midi.h"  #include "midictrl.h"  #include "al/xml.h" -#include "driver/mididev.h"  #include "driver/audiodev.h"  #include "audio.h"  #include "gconfig.h" @@ -57,8 +56,8 @@ MidiInPort::~MidiInPort()  void MidiInPort::setName(const QString& s)        {        Track::setName(s); -      if (!alsaPort(0).isZero()) -            midiDriver->setPortName(alsaPort(), s); +//      if (!alsaPort(0).isZero()) +//            midiDriver->setPortName(alsaPort(), s);        if (!jackPort(0).isZero())              audioDriver->setPortName(jackPort(), s);        } @@ -89,12 +88,12 @@ void MidiInPort::read(QDomNode node)              }        } +#if 0  //---------------------------------------------------------  //   midiReceived  //    called from midiSeq context  //--------------------------------------------------------- -#ifndef __APPLE__  void MidiInPort::eventReceived(snd_seq_event_t* ev)        {        MidiEvent event; diff --git a/muse/muse/midiinport.h b/muse/muse/midiinport.h index b50c9207..c1fdf3ac 100644 --- a/muse/muse/midiinport.h +++ b/muse/muse/midiinport.h @@ -50,9 +50,8 @@ class MidiInPort : public MidiTrackBase {        virtual bool isMute() const         { return _mute; }        virtual Part* newPart(Part*, bool)  { return 0; } -#ifndef __APPLE__ -      void eventReceived(snd_seq_event_t*); -#endif +//      void eventReceived(snd_seq_event_t*); +        virtual void getEvents(unsigned from, unsigned to, int channel, MidiEventList* dst);        void beforeProcess();        void afterProcess(); diff --git a/muse/muse/midioutport.cpp b/muse/muse/midioutport.cpp index a9cf9438..e385529a 100644 --- a/muse/muse/midioutport.cpp +++ b/muse/muse/midioutport.cpp @@ -24,11 +24,9 @@  #include "al/al.h"  #include "al/tempo.h"  #include "al/xml.h" -#include "driver/mididev.h"  #include "driver/audiodev.h"  #include "audio.h"  #include "midioutport.h" -#include "midiseq.h"  #include "sync.h"  #include "gconfig.h"  #include "instruments/minstrument.h" @@ -64,8 +62,8 @@ MidiOutPort::~MidiOutPort()  void MidiOutPort::setName(const QString& s)        {        Track::setName(s); -      if (!alsaPort().isZero()) -            midiDriver->setPortName(alsaPort(), s); +//      if (!alsaPort().isZero()) +//            midiDriver->setPortName(alsaPort(), s);        if (!jackPort().isZero())              audioDriver->setPortName(jackPort(), s);  //      for (int ch = 0; ch < MIDI_CHANNELS; ++ch) @@ -125,9 +123,6 @@ void MidiOutPort::routeEvent(const MidiEvent& event)        {        for (iRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r) {              switch (r->dst.type) { -                  case RouteNode::MIDIPORT: -                        queueAlsaEvent(event); -                        break;                    case RouteNode::JACKMIDIPORT:                          queueJackEvent(event);                          break; @@ -139,98 +134,6 @@ void MidiOutPort::routeEvent(const MidiEvent& event)        }  //--------------------------------------------------------- -//    queueAlsaEvent -//    called from MidiSeq -//--------------------------------------------------------- - -#define AO(e) midiSeq->putEvent(alsaPort(0), e); - -void MidiOutPort::queueAlsaEvent(const MidiEvent& ev) -      { -      if (ev.type() == ME_CONTROLLER) { -            int a      = ev.dataA(); -            int b      = ev.dataB(); -            int chn    = ev.channel(); -            unsigned t = ev.time(); - -            if (a == CTRL_PITCH) { -                  AO(MidiEvent(t, chn, ME_PITCHBEND, b, 0)); -                  } -            else if (a == CTRL_PROGRAM) { -                  int hb = (b >> 16) & 0xff; -                  int lb = (b >> 8) & 0xff; -                  int pr = b & 0x7f; -                  if (hb != 0xff) -                        AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HBANK, hb)); -                  if (lb != 0xff) -                        AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LBANK, lb)); -                  AO(MidiEvent(t+2, chn, ME_PROGRAM, pr, 0)); -                  } -            else if (a == CTRL_MASTER_VOLUME) { -                  unsigned char sysex[] = { -                        0x7f, 0x7f, 0x04, 0x01, 0x00, 0x00 -                        }; -                  sysex[1] = deviceId(); -                  sysex[4] = b & 0x7f; -                  sysex[5] = (b >> 7) & 0x7f; -                  AO(MidiEvent(t, ME_SYSEX, sysex, 6)); -                  } -            else if (a < CTRL_14_OFFSET) {               // 7 Bit Controller -                  AO(ev); -                  } -            else if (a < CTRL_RPN_OFFSET) {     // 14 bit high resolution controller -                  int ctrlH = (a >> 8) & 0x7f; -                  int ctrlL = a & 0x7f; -                  int dataH = (b >> 7) & 0x7f; -                  int dataL = b & 0x7f; -                  AO(MidiEvent(t, chn, ME_CONTROLLER, ctrlH, dataH)); -                  AO(MidiEvent(t+1, chn, ME_CONTROLLER, ctrlL, dataL)); -                  } -            else if (a < CTRL_NRPN_OFFSET) {     // RPN 7-Bit Controller -                  int ctrlH = (a >> 8) & 0x7f; -                  int ctrlL = a & 0x7f; -                  AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)); -                  AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)); -                  AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b)); -                  } -            else if (a < CTRL_RPN14_OFFSET) {     // NRPN 7-Bit Controller -                  int ctrlH = (a >> 8) & 0x7f; -                  int ctrlL = a & 0x7f; -                  AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); -                  AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); -                  AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b)); -                  } -            else if (a < CTRL_NRPN14_OFFSET) {     // RPN14 Controller -                  int ctrlH = (a >> 8) & 0x7f; -                  int ctrlL = a & 0x7f; -                  int dataH = (b >> 7) & 0x7f; -                  int dataL = b & 0x7f; -                  AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)); -                  AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)); -                  AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH)); -                  AO(MidiEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL)); -                  } -            else if (a < CTRL_NONE_OFFSET) {     // NRPN14 Controller -                  int ctrlH = (a >> 8) & 0x7f; -                  int ctrlL = a & 0x7f; -                  int dataH = (b >> 7) & 0x7f; -                  int dataL = b & 0x7f; -                  AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); -                  AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); -                  AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH)); -                  AO(MidiEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL)); -                  } -            else { -                  printf("putEvent: unknown controller type 0x%x\n", a); -                  } -            } -      else { -            AO(ev); -            } -      } -#undef AO - -//---------------------------------------------------------  //    queueJackEvent  //    called from MidiSeq  //--------------------------------------------------------- diff --git a/muse/muse/midiseq.cpp b/muse/muse/midiseq.cpp deleted file mode 100644 index 8714257c..00000000 --- a/muse/muse/midiseq.cpp +++ /dev/null @@ -1,223 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "midiseq.h" -#include "audio.h" -#include "driver/mididev.h" -#include "driver/audiodev.h" - -#ifdef __APPLE__ -#include "driver/coretimer.h" -#else -#include "driver/rtctimer.h" -#include "driver/posixtimer.h" -#include "driver/alsatimer.h" -#endif - -#include "sync.h" -#include "song.h" -#include "gconfig.h" - -MidiSeq* midiSeq; - -//--------------------------------------------------------- -//   MidiSeq -//--------------------------------------------------------- - -MidiSeq::MidiSeq(const char* name) -   : Thread(name) -      { -      timer = 0; -      } - -//--------------------------------------------------------- -//   threadStart -//    called from loop() -//--------------------------------------------------------- - -void MidiSeq::threadStart(void*) -      { -      struct sched_param rt_param; -      memset(&rt_param, 0, sizeof(rt_param)); - -      int prio_min = sched_get_priority_min(SCHED_FIFO); -      int prio_max = sched_get_priority_max(SCHED_FIFO); -	int prio     = realTimePriority; -      if (prio < prio_min) -            prio = prio_min; -      else if (prio > prio_max) -            prio = prio_max; -      rt_param.sched_priority = prio; - -      pthread_t tid = pthread_self(); -      int rv = pthread_setschedparam(tid, SCHED_FIFO, &rt_param); -      if (rv != 0) -            perror("set realtime scheduler"); - -      int policy; -#ifdef __APPLE__ -      if (0) { -#else -      if ( (policy = sched_getscheduler (0)) < 0) { -#endif -            printf("cannot get current client scheduler for midi thread: %s!\n", strerror(errno)); -            } -      else { -            if (policy != SCHED_FIFO) -                  printf("midi thread %d _NOT_ running SCHED_FIFO\n", getpid()); -            else if (debugMsg) { -            	struct sched_param rt_param; -            	memset(&rt_param, 0, sizeof(sched_param)); -            	int type; -            	int rv = pthread_getschedparam(pthread_self(), &type, &rt_param); -            	if (rv == -1) -                  	perror("get scheduler parameter"); -                  printf("midiseq thread running SCHED_FIFO priority %d\n", -                     rt_param.sched_priority); -                  } -            } - -#ifdef __APPLE__ -            timer = new CoreTimer; -#else -//      timer = new PosixTimer; -//      if (!timer->initTimer()) { -//            delete timer; -            timer = new RtcTimer; -            if (!timer->initTimer()) { -                  delete timer; -                  timer = new AlsaTimer; -                  if (!timer->initTimer()) { -                        fprintf(stderr, "no midi timer available\n"); -                        abort(); -                        } -                  } -//            } -#endif -      initRealtimeTimer(); -      updatePollFd(); -      } - -//--------------------------------------------------------- -//   midiRead -//--------------------------------------------------------- - -static void midiRead(void*, void*) -      { -      midiDriver->read(midiSeq); -      } - -//--------------------------------------------------------- -//   updatePollFd -//--------------------------------------------------------- - -void MidiSeq::updatePollFd() -      { -      if (!isRunning()) -            return; -      clearPollFd(); - -      if (timer) { -            int timerFd = timer->getFd(); -            if (timerFd != -1) -                  addPollFd(timerFd, POLLIN, midiTick, this, 0); -            } -//      addPollFd(toThreadFdr, POLLIN, ::readMsg, this, 0); - -      struct pollfd* pfd; -      int n; -      midiDriver->getInputPollFd(&pfd, &n); -      for (int i = 0; i < n; ++i) -            addPollFd(pfd[i].fd, POLLIN, ::midiRead, this, 0); -//      midiDriver->getOutputPollFd(&pfd, &n); -//      for (int i = 0; i < n; ++i) -//            addPollFd(pfdi[i].fd, POLLOUT, ::midiWrite, this, 0); -      } - -//--------------------------------------------------------- -//   threadStop -//    called from loop() -//--------------------------------------------------------- - -void MidiSeq::threadStop() -      { -      if (timer) -	      timer->stopTimer(); -      } - -//--------------------------------------------------------- -//   setRtcTicks -//    return true on success -//--------------------------------------------------------- - -bool MidiSeq::initRealtimeTimer() -      { -      if (!timer) -            return false; -      if (!timer->setTimerFreq(config.rtcTicks)) -            return false; -      if (!timer->startTimer()) -            return false; -      realRtcTicks = config.rtcTicks; -      return true; -      } - -//--------------------------------------------------------- -//   start -//    return true on error -//--------------------------------------------------------- - -bool MidiSeq::start(int prio) -      { -      Thread::start(prio); -      return false; -      } - -//--------------------------------------------------------- -//   midiTick -//    schedule events in playEvents -//    "now" is the free running audioDriver->frameTime() -//    frame counter -//--------------------------------------------------------- - -void MidiSeq::midiTick(void* p, void*) -      { -      extern int watchMidi; -      ++watchMidi;            // make a simple watchdog happy - -      MidiSeq* at = (MidiSeq*)p; -      at->getTimerTicks();    // read elapsed rtc timer ticks - -      while (!at->fifo.isEmpty()) -            at->playEvents.insert(at->fifo.get()); - -      // -      // schedule all events upto curFrame() -      // -      unsigned curFrame = audioDriver->frameTime(); -      iMidiOutEvent i   = at->playEvents.begin(); -      for (; i != at->playEvents.end(); ++i) { -            if (i->event.time() > curFrame) -                  break; -            midiDriver->putEvent(i->port, i->event); -            } -      at->playEvents.erase(at->playEvents.begin(), i); -      } - diff --git a/muse/muse/midiseq.h b/muse/muse/midiseq.h deleted file mode 100644 index a684886e..00000000 --- a/muse/muse/midiseq.h +++ /dev/null @@ -1,56 +0,0 @@ -//============================================================================= -//  MusE -//  Linux Music Editor -//  $Id:$ -// -//  Copyright (C) 2002-2006 by Werner Schweer and others -// -//  This program is free software; you can redistribute it and/or modify -//  it under the terms of the GNU General Public License version 2. -// -//  This program is distributed in the hope that it will be useful, -//  but WITHOUT ANY WARRANTY; without even the implied warranty of -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -//  GNU General Public License for more details. -// -//  You should have received a copy of the GNU General Public License -//  along with this program; if not, write to the Free Software -//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __MIDISEQ_H__ -#define __MIDISEQ_H__ - -#include "thread.h" -#include "driver/timerdev.h" -#include "midififo.h" - -//--------------------------------------------------------- -//   MidiSeq -//--------------------------------------------------------- - -class MidiSeq : public Thread { -      int realRtcTicks; -      Timer* timer; - -      MidiOutFifo fifo; -      MidiOutEventList playEvents; - -      static void midiTick(void* p, void*); -      int getTimerTicks() { return timer->getTimerTicks(); } - -   public: -      MidiSeq(const char* name); -      bool start(int); -      virtual void threadStop(); -      virtual void threadStart(void*); -      void updatePollFd(); -      bool initRealtimeTimer(); -      void putEvent(const Port& p, const MidiEvent& e) {  -            fifo.put(MidiOutEvent(p,e));  -            } -      }; - -extern MidiSeq* midiSeq; -#endif - diff --git a/muse/muse/mixer/mstrip.cpp b/muse/muse/mixer/mstrip.cpp index 5c1f2e34..bf2238ea 100644 --- a/muse/muse/mixer/mstrip.cpp +++ b/muse/muse/mixer/mstrip.cpp @@ -25,7 +25,6 @@  #include "mixer.h"  #include "widgets/simplebutton.h"  #include "widgets/utils.h" -#include "driver/mididev.h"  #include "driver/audiodev.h"  #include "synth.h"  #include "midirack.h" @@ -801,26 +800,12 @@ void MidiOutPortStrip::oRouteShow()        {        QMenu* pup = oR->menu();        pup->clear(); -      pup->addSeparator()->setText(tr("AlsaDevices"));        RouteList* orl = track->outRoutes(); -      // -      // add ALSA midi ports to list -      // -      QList<PortName> ol = midiDriver->outputPorts(true); -      foreach (PortName ip, ol) { -            QAction* oa = pup->addAction(ip.name); -            oa->setCheckable(true); -            RouteNode dst(ip.port, RouteNode::MIDIPORT); -            Route r = Route(RouteNode(track), dst); -            oa->setData(QVariant::fromValue(r)); -            oa->setChecked(orl->indexOf(r) != -1); -            } - +      QList<PortName> ol;        //        // add JACK midi ports to list        // -      pup->addSeparator()->setText(tr("JackDevices"));        ol = audioDriver->inputPorts(true);        foreach (PortName ip, ol) {              QAction* oa = pup->addAction(ip.name); @@ -990,23 +975,13 @@ void MidiInPortStrip::iRouteShow()        {        QMenu* pup = iR->menu();        pup->clear(); -      pup->addSeparator()->setText(tr("AlsaDevices"));        RouteList* irl = track->inRoutes(); -      QList<PortName> ol = midiDriver->inputPorts(false); -      foreach (PortName ip, ol) { -            RouteNode src(ip.port, RouteNode::MIDIPORT); -            Route r = Route(src, RouteNode(track)); -            QAction* action = pup->addAction(ip.name); -            action->setCheckable(true); -            action->setData(QVariant::fromValue(r)); -            action->setChecked(irl->indexOf(r) != -1); -            } +      QList<PortName> ol;        //        // add JACK midi ports to list        // -      pup->addSeparator()->setText(tr("JackDevices"));        ol = audioDriver->outputPorts(true);        foreach (PortName ip, ol) {              QAction* action = pup->addAction(ip.name); diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index 9ad28877..54b2569c 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -45,7 +45,6 @@  #include "transpose.h"  #include "preferences.h"  #include "audio.h" -#include "midiseq.h"  #include "audioprefetch.h"  #include "audiowriteback.h"  #include "widgets/shortcutconfig.h" @@ -54,11 +53,6 @@  #include "song.h"  #include "awl/poslabel.h"  #include "shortcuts.h" -#ifdef __APPLE__ -#include "driver/coremidi.h" -#else -#include "driver/alsamidi.h" -#endif  #include "midiplugin.h"  #include "midiedit/drummap.h"  #include "widgets/utils.h" @@ -111,61 +105,6 @@ static RasterVal rasterTable[] = {        };  //--------------------------------------------------------- -//   watchdog thread -//	realtime priorities are: -//	   realTimePriority	- priority of jack thread -//	   realTimePriority+1	- priority of midi thread -//	   realTimePriority+2	- priority of watchdog thread -//--------------------------------------------------------- - -static void* watchdog(void*) -      { -      int policy; -#ifndef __APPLE__ -      if ((policy = sched_getscheduler (0)) < 0) -            printf("Cannot get current client scheduler: %s\n", strerror(errno)); -      if (policy != SCHED_FIFO) -            printf("MusE: watchdog process _NOT_ running SCHED_FIFO\n"); -#endif -      int fatal = 0; -      for (;;) { -            watchAudio = 0; -            watchMidi = 0; -            static const int WD_TIMEOUT = 3; - -            int to = WD_TIMEOUT; -            while (to > 0)           // sleep can be interrupted by signal -                  to = sleep(to); - -            bool timeout = false; -            if (watchMidi == 0) -                  timeout = true; -            if (watchAudio == 0) -                  timeout = true; -            if (watchAudio > 500000) -                  timeout = true; -            if (watchMidi > (config.rtcTicks * WD_TIMEOUT * 2)) -                  timeout = true; -            if (timeout) -                  ++fatal; -            else -                  fatal = 0; -            if (fatal >= 3) { -                  printf("MusE: WatchDog: fatal error, realtime task timeout\n"); -                  printf("   (%d,%d-%d) - stopping all services\n", -                     watchMidi, watchAudio, fatal); -                  break; -                  } -//            printf("wd %d %d %d\n", watchMidi, watchAudio, fatal); -            } -      audio->stop(); -      audioWriteback->stop(true); -      audioPrefetch->stop(true); -      fatalError("watchdog timeout"); -      return 0; -      } - -//---------------------------------------------------------  //   seqStart  //--------------------------------------------------------- @@ -198,58 +137,15 @@ bool MusE::seqStart()        // priority        realTimePriority = audioDriver->realtimePriority(); - -      // -      //  create midi thread with a higher priority than JACK -      // -      midiSeq->start(realTimePriority ? realTimePriority + 2 : 0); - +      audioState = AUDIO_RUNNING;        if (realTimePriority) { -            // -            //  create watchdog thread with realTimePriority+2 -            // -            int priority = realTimePriority + 3; -            struct sched_param rt_param; -            memset(&rt_param, 0, sizeof(rt_param)); -            rt_param.sched_priority = priority; - -            pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t)); -            pthread_attr_init(attributes); - -            if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) { -                  printf("MusE: cannot set FIFO scheduling class for RT thread\n"); -                  } -            if (pthread_attr_setschedparam (attributes, &rt_param)) { -                  // printf("Cannot set scheduling priority for RT thread (%s)\n", strerror(errno)); -                  } -            if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) { -                  printf("MusE: Cannot set scheduling scope for RT thread\n"); -                  } -            if (pthread_attr_setinheritsched(attributes, PTHREAD_EXPLICIT_SCHED)) { -                  printf("Cannot set setinheritsched for RT thread\n"); -                  } -            int rv; -            if ((rv = pthread_create(&watchdogThread, attributes, ::watchdog, 0))) -                  fprintf(stderr, "MusE: creating watchdog thread failed: %s\n", -            	   strerror(rv)); -            pthread_attr_destroy(attributes); -            // -            // start audio prefetch threads with realtime -            // priority -            // -            audioPrefetch->start(realTimePriority-5); -            audioWriteback->start(realTimePriority-5); +            audioPrefetch->start(realTimePriority - 5); +            audioWriteback->start(realTimePriority - 5);              }        else { -            printf("MusE: Warning - starting threads without realtime priority since audio is not running realtime.\n"); -            // -            // start audio prefetch threads as normal -            // (non realtime) threads -            //              audioPrefetch->start(0);              audioWriteback->start(0);              } -      audioState = AUDIO_RUNNING;        //        // do connections        // @@ -265,10 +161,8 @@ bool MusE::seqStart()  void MusE::seqStop()        { -//      audio->msgIdle(true);        song->setStop(true);        song->setStopPlay(false); -      midiSeq->stop(true);        audio->stop();        audioWriteback->stop(true);        audioPrefetch->stop(true); @@ -532,26 +426,6 @@ MusE::MusE()        redoAction->setEnabled(false);        connect(redoAction, SIGNAL(triggered()), song, SLOT(redo())); -#ifdef __APPLE__ -      if (coreMidi.init()) { -          QMessageBox::critical(NULL, "MusE fatal error.", -            "MusE failed to initialize the\n" -            "Core midi subsystem, check\n" -            "your configuration."); -          fatalError("init core-midi failed"); -          } -      midiDriver = &coreMidi; -#else -      if (alsaMidi.init()) { -          QMessageBox::critical(NULL, "MusE fatal error.", -            "MusE failed to initialize the\n" -            "Alsa midi subsystem, check\n" -            "your configuration."); -          fatalError("init alsa failed"); -          } -      midiDriver = &alsaMidi; -#endif -        fileOpenAction = getAction("open_project", this);        connect(fileOpenAction, SIGNAL(triggered()), SLOT(loadProject())); @@ -600,7 +474,6 @@ MusE::MusE()        audio          = new Audio();        audioPrefetch  = new AudioPrefetch("Prefetch");        audioWriteback = new AudioWriteback("Writeback"); -      midiSeq        = new MidiSeq("Midi");        //---------------------------------------------------        //    MenuBar diff --git a/muse/muse/preferences.cpp b/muse/muse/preferences.cpp index 84c2fe98..ef3d23b1 100644 --- a/muse/muse/preferences.cpp +++ b/muse/muse/preferences.cpp @@ -34,7 +34,6 @@  #include "audio.h"  #include "mixer/mixer.h"  #include "midirc.h" -#include "driver/mididev.h"  #include "instruments/minstrument.h"  #include "midiedit/pianoroll.h"  #include "midiedit/drumedit.h" @@ -223,22 +222,7 @@ PreferencesDialog::PreferencesDialog(Arranger* a, QWidget* parent)                    break;                    }              } -      QList<PortName> ol = midiDriver->inputPorts(true);        int i = 0; -      for (QList<PortName>::iterator ip = ol.begin(); ip != ol.end(); ++ip, ++i) { -            preferredInput->addItem(ip->name); -            if (ip->name == config->defaultMidiInputDevice) -                  preferredInput->setCurrentIndex(i); -            } -      ol = midiDriver->outputPorts(true); -      i = 0; -      for (QList<PortName>::iterator ip = ol.begin(); ip != ol.end(); ++ip, ++i) { -            preferredOutput->addItem(ip->name); -            if (ip->name == config->defaultMidiOutputDevice) -                  preferredOutput->setCurrentIndex(i); -            } - -      i = 0;        for (iMidiInstrument mi = midiInstruments.begin(); mi != midiInstruments.end(); ++mi, ++i) {              preferredInstrument->addItem((*mi)->iname());              if ((*mi)->iname() == config->defaultMidiInstrument) diff --git a/muse/muse/route.cpp b/muse/muse/route.cpp index 7d4d364c..dee6c03c 100644 --- a/muse/muse/route.cpp +++ b/muse/muse/route.cpp @@ -24,7 +24,6 @@  #include "track.h"  #include "synth.h"  #include "driver/audiodev.h" -#include "driver/mididev.h"  #include "al/xml.h"  #include "auxplugin.h" @@ -85,8 +84,7 @@ bool addRoute(const Route& r)  //         r.src.tname(), r.src.channel, r.src.name().toLatin1().data(),  //         r.dst.tname(), r.dst.channel, r.dst.name().toLatin1().data()); -      if (r.src.type == RouteNode::AUDIOPORT || r.src.type == RouteNode::MIDIPORT  -         || r.src.type == RouteNode::JACKMIDIPORT) { +      if (r.src.type == RouteNode::AUDIOPORT || r.src.type == RouteNode::JACKMIDIPORT) {              if (r.dst.type != RouteNode::TRACK) {                    fprintf(stderr, "addRoute: bad route 1\n");                    return false; @@ -102,8 +100,7 @@ bool addRoute(const Route& r)                    }              inRoutes->push_back(r);              } -      else if (r.dst.type == RouteNode::AUDIOPORT || r.dst.type == RouteNode::MIDIPORT -         || r.dst.type == RouteNode::JACKMIDIPORT) { +      else if (r.dst.type == RouteNode::AUDIOPORT || r.dst.type == RouteNode::JACKMIDIPORT) {              if (r.src.type != RouteNode::TRACK) {                    fprintf(stderr, "addRoute: bad route 3\n");                    return false; @@ -143,8 +140,7 @@ void removeRoute(const Route& r)  //      printf("removeRoute %s.%d:<%s> %s.%d:<%s>\n",  //         r.src.tname(), r.src.channel, r.src.name().toLatin1().data(),  //         r.dst.tname(), r.dst.channel, r.dst.name().toLatin1().data()); -      if (r.src.type == RouteNode::AUDIOPORT || r.src.type == RouteNode::MIDIPORT -         || r.src.type == RouteNode::JACKMIDIPORT) { +      if (r.src.type == RouteNode::AUDIOPORT || r.src.type == RouteNode::JACKMIDIPORT) {              if (r.dst.type != RouteNode::TRACK) {                    fprintf(stderr, "removeRoute: bad route 1\n");                    goto error; @@ -164,8 +160,7 @@ void removeRoute(const Route& r)                          }                    }              } -      else if (r.dst.type == RouteNode::AUDIOPORT || r.dst.type == RouteNode::MIDIPORT -         || r.dst.type == RouteNode::JACKMIDIPORT) { +      else if (r.dst.type == RouteNode::AUDIOPORT || r.dst.type == RouteNode::JACKMIDIPORT) {              if (r.src.type != RouteNode::TRACK) {                    fprintf(stderr, "removeRoute: bad route 3\n");                    goto error; @@ -245,10 +240,6 @@ QString RouteNode::name() const                    if (port.isZero())                          return QString("0");                    return audioDriver->portName(port); -            case MIDIPORT: -                  if (port.isZero()) -                        return QString("0"); -                  return midiDriver->portName(port);              case AUXPLUGIN:                    return plugin->pluginInstance()->name();              } @@ -309,7 +300,6 @@ bool RouteNode::operator==(const RouteNode& a) const        switch(type) {              case TRACK:                    return (channel == a.channel) && (track == a.track); -            case MIDIPORT:              case JACKMIDIPORT:              case AUDIOPORT:                    return port == a.port; @@ -326,7 +316,7 @@ bool RouteNode::operator==(const RouteNode& a) const  const char* RouteNode::tname(RouteNodeType t)        {        static const char* names[] = { -            "TRACK", "AUDIOPORT", "MIDIPORT", "JACKMIDIPORT", "AUX" +            "TRACK", "AUDIOPORT", "JACKMIDIPORT", "AUX"              };        if (t > (int)(sizeof(names)/sizeof(*names)))              return "???"; @@ -389,12 +379,6 @@ void RouteNode::read(QDomNode node)              if (port.isZero())                    printf("Route::read(): jack midiport <%s> not found\n", s.toLatin1().data());              } -      else if (st == "MIDIPORT") { -            type = RouteNode::MIDIPORT; -            port = midiDriver->findPort(s); -            if (port.isZero()) -                  printf("Route::read(): midiport <%s> not found\n", s.toLatin1().data()); -            }        else if (st == "AUX") {              type = RouteNode::AUXPLUGIN;              plugin = 0; diff --git a/muse/muse/route.h b/muse/muse/route.h index 531be751..48300c60 100644 --- a/muse/muse/route.h +++ b/muse/muse/route.h @@ -41,8 +41,8 @@ using AL::Xml;  //---------------------------------------------------------  struct RouteNode { -      enum RouteNodeType {  -            TRACK, AUDIOPORT, MIDIPORT, JACKMIDIPORT, AUXPLUGIN +      enum RouteNodeType { +            TRACK, AUDIOPORT, JACKMIDIPORT, AUXPLUGIN              };        Port   port; @@ -61,7 +61,7 @@ struct RouteNode {        RouteNode(AuxPluginIF*);        bool isPortType() const { -            return type==AUDIOPORT || type == MIDIPORT || type == JACKMIDIPORT; +            return type==AUDIOPORT || type == JACKMIDIPORT;              }        bool isValid() const {              return (isPortType() && !port.isZero()) @@ -90,7 +90,7 @@ struct Route {        Route() { disconnected = false;}        Route(const RouteNode& s, const RouteNode& d) : src(s), dst(d) { disconnected = false;} -      bool operator==(const Route& a) const {  +      bool operator==(const Route& a) const {              return (src==a.src) && (dst==a.dst);              }        }; diff --git a/muse/muse/seqmsg.cpp b/muse/muse/seqmsg.cpp index 73f57a68..ec22926a 100644 --- a/muse/muse/seqmsg.cpp +++ b/muse/muse/seqmsg.cpp @@ -26,7 +26,6 @@  #include "al/sig.h"  #include "audio.h"  #include "driver/audiodev.h" -#include "driver/mididev.h"  #include "audio.h"  #include "arranger/arranger.h"  #include "plugin.h" @@ -102,16 +101,10 @@ void Audio::msgRemoveRoute(Route r)        else if (r.src.type == RouteNode::JACKMIDIPORT) {              audioDriver->disconnect(r.src.port, ((MidiInPort*)r.dst.track)->jackPort());              } -      else if (r.src.type == RouteNode::MIDIPORT) { -            midiDriver->disconnect(r.src.port, ((MidiInPort*)r.dst.track)->alsaPort()); -            }        else if (r.dst.type == RouteNode::AUDIOPORT) {              AudioOutput* ai = (AudioOutput*)(r.src.track);              audioDriver->disconnect(ai->jackPort(r.src.channel), r.dst.port);              } -      else if (r.dst.type == RouteNode::MIDIPORT) { -            midiDriver->disconnect(((MidiOutPort*)r.src.track)->alsaPort(), r.dst.port); -            }        else if (r.dst.type == RouteNode::JACKMIDIPORT) {              audioDriver->disconnect(((MidiOutPort*)r.src.track)->jackPort(), r.dst.port);              } @@ -144,17 +137,11 @@ void Audio::msgAddRoute(Route r)        else if (r.src.type == RouteNode::JACKMIDIPORT) {              audioDriver->connect(r.src.port, ((MidiInPort*)r.dst.track)->jackPort());              } -      else if (r.src.type == RouteNode::MIDIPORT) { -            midiDriver->connect(r.src.port, ((MidiInPort*)r.dst.track)->alsaPort()); -            }        else if (r.dst.type == RouteNode::AUDIOPORT) {              AudioOutput* ao = (AudioOutput*)r.src.track;  printf("msgAddRoute to AUDIPORT %p\n", ao);              audioDriver->connect(ao->jackPort(r.src.channel), r.dst.port);              } -      else if (r.dst.type == RouteNode::MIDIPORT) { -            midiDriver->connect(((MidiOutPort*)r.src.track)->alsaPort(), r.dst.port); -            }        else if (r.dst.type == RouteNode::JACKMIDIPORT) {              audioDriver->connect(((MidiOutPort*)r.src.track)->jackPort(), r.dst.port);              } diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index ea374b5c..dd162410 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -27,7 +27,6 @@  #include "midiedit/drummap.h"  #include "audio.h"  #include "mixer/mixer.h" -#include "midiseq.h"  #include "driver/audiodev.h"  #include "gconfig.h"  #include "al/marker.h" diff --git a/muse/muse/songfile.cpp b/muse/muse/songfile.cpp index 14c044a6..4f701bae 100644 --- a/muse/muse/songfile.cpp +++ b/muse/muse/songfile.cpp @@ -27,7 +27,6 @@  #include "al/marker.h"  #include "midictrl.h"  #include "conf.h" -#include "midiseq.h"  #include "al/tempo.h"  #include "al/sig.h"  #include "synth.h" diff --git a/muse/muse/songtrack.cpp b/muse/muse/songtrack.cpp index ff54d3af..642926ac 100644 --- a/muse/muse/songtrack.cpp +++ b/muse/muse/songtrack.cpp @@ -22,7 +22,6 @@  #include "audio.h"  #include "midiplugin.h"  #include "driver/audiodev.h" -#include "driver/mididev.h"  #include "muse.h"  //--------------------------------------------------------- @@ -105,7 +104,7 @@ Track* Song::addTrack(QAction* action)              MidiSynti* si = new MidiSynti();              QString sName(s->name());              for (k = s->instances(); k < 1000; ++k) { -                  QString instanceName = (k == 0) ?  +                  QString instanceName = (k == 0) ?                       sName : instanceName.arg(sName).arg(k);                    MidiSyntiList* sl = midiSyntis(); @@ -138,7 +137,7 @@ Track* Song::addTrack(QAction* action)              SynthI* si = new SynthI();              int i;              for (i = s->instances(); i < 1000; ++i) { -                  QString instanceName = (i == 0) ?  +                  QString instanceName = (i == 0) ?                       s->name() : QString("%1-%2").arg(s->name()).arg(i);                    SynthIList* sl = syntis(); @@ -225,6 +224,7 @@ void Song::insertTrack(Track* track, int idx)              case Track::TRACK_TYPES:              case Track::MIDI_OUT:                    { +#if 0                    QList<PortName> op = midiDriver->outputPorts(false);                    if (!op.isEmpty()) {                          RouteNode src(track); @@ -232,12 +232,14 @@ void Song::insertTrack(Track* track, int idx)                          Route r = Route(src, dst);                          track->addOutRoute(r);                          } +#endif                    //TODO: autoconnect to JACK midi ports                    }                    break; -                   +              case Track::MIDI_IN:                    { +#if 0                    QList<PortName> op = midiDriver->inputPorts(true);                    if (!op.isEmpty()) {                          RouteNode src(op.back().port, -1, RouteNode::MIDIPORT); @@ -245,6 +247,7 @@ void Song::insertTrack(Track* track, int idx)                          Route r = Route(src, dst);                          track->addInRoute(r);                          } +#endif                    //TODO: autoconnect to JACK midi ports                    }                    break; @@ -253,7 +256,7 @@ void Song::insertTrack(Track* track, int idx)                    break;              case Track::MIDI:                    // -                  // connect to first channel of all all midi input ports,  +                  // connect to first channel of all all midi input ports,                    // if there is not already a route                    //                    if (track->noInRoute()) { diff --git a/muse/muse/sync.cpp b/muse/muse/sync.cpp index d089ce80..e72c143c 100644 --- a/muse/muse/sync.cpp +++ b/muse/muse/sync.cpp @@ -22,7 +22,6 @@  #include "song.h"  #include "widgets/utils.h"  #include "globals.h" -#include "midiseq.h"  #include "audio.h"  #include "driver/audiodev.h"  #include "gconfig.h" diff --git a/muse/muse/synth.cpp b/muse/muse/synth.cpp index 6cd14761..4445dbcc 100644 --- a/muse/muse/synth.cpp +++ b/muse/muse/synth.cpp @@ -32,7 +32,6 @@  #include "event.h"  #include "midievent.h"  #include "audio.h" -#include "midiseq.h"  #include "midictrl.h"  #include "instruments/minstrument.h"  #include "driver/audiodev.h" diff --git a/muse/muse/track.cpp b/muse/muse/track.cpp index 7d78c7a8..7b7df1ce 100644 --- a/muse/muse/track.cpp +++ b/muse/muse/track.cpp @@ -29,7 +29,6 @@  #include "part.h"  #include "gui.h"  #include "driver/audiodev.h" -#include "driver/mididev.h"  // synchronize with TrackType!: @@ -48,7 +47,7 @@ const char* Track::_clname[] = {  //   ArrangerTrack  //--------------------------------------------------------- -ArrangerTrack::ArrangerTrack()  +ArrangerTrack::ArrangerTrack()  	{  	tw   = 0;        ctrl = -1;        // first ctrl in list @@ -122,12 +121,12 @@ Track::~Track()        delete _parts;        for (int i = 0; i < MAX_CHANNELS; ++i) { -            if (!_alsaPort[i].isZero()) -                  midiDriver->unregisterPort(_alsaPort[i]); +//            if (!_alsaPort[i].isZero()) +//                  midiDriver->unregisterPort(_alsaPort[i]);              if (!_jackPort[i].isZero())                    audioDriver->unregisterPort(_jackPort[i]);              } -       +        }  //--------------------------------------------------------- @@ -824,16 +823,12 @@ void Track::resetAllMeter()  void Track::activate1()        {        if (isMidiTrack()) { -            if (!alsaPort(0).isZero()) -                  printf("Track::activate1() midi: alsa port already active!\n");              if (!jackPort(0).isZero())                    printf("Track::activate1() midi: jack port already active!\n");              if (type() == MIDI_OUT) { -                  _alsaPort[0] = midiDriver->registerInPort(_name, true);                    _jackPort[0] = audioDriver->registerOutPort(_name, true);                    }              else if (type() == MIDI_IN) { -                  _alsaPort[0] = midiDriver->registerOutPort(_name, true);                    _jackPort[0] = audioDriver->registerInPort(_name, true);                    }              return; @@ -874,10 +869,6 @@ void Track::activate2()                    audioDriver->connect(_jackPort[r.src.channel], r.dst.port);                    r.disconnected = false;                    } -            else if (r.dst.type == RouteNode::MIDIPORT) { -                  midiDriver->connect(_alsaPort[0], r.dst.port); -                  r.disconnected = false; -                  }              }        foreach(Route r, _inRoutes) {              if (r.src.type == RouteNode::JACKMIDIPORT) { @@ -888,10 +879,6 @@ void Track::activate2()                    audioDriver->connect(r.src.port, _jackPort[r.dst.channel]);                    r.disconnected = false;                    } -            else if (r.src.type == RouteNode::MIDIPORT) { -                  midiDriver->connect(r.src.port, _alsaPort[0]); -                  r.disconnected = false; -                  }              }        } @@ -912,10 +899,6 @@ void Track::deactivate()                    audioDriver->disconnect(_jackPort[r.src.channel], r.dst.port);                    r.disconnected = true;                    } -            else if (r.dst.type == RouteNode::MIDIPORT) { -                  r.disconnected = true; -                  midiDriver->disconnect(_alsaPort[0], r.dst.port); -                  }              }        foreach(Route r, _inRoutes) {              if (r.src.type == RouteNode::JACKMIDIPORT) { @@ -926,20 +909,12 @@ void Track::deactivate()                    r.disconnected = true;                    audioDriver->disconnect(r.src.port, _jackPort[r.dst.channel]);                    } -            else if (r.src.type == RouteNode::MIDIPORT) { -                  r.disconnected = true; -                  midiDriver->disconnect(r.src.port, _alsaPort[0]); -                  }              }        for (int i = 0; i < channels(); ++i) {              if (!_jackPort[i].isZero()) {                    audioDriver->unregisterPort(_jackPort[i]);                    _jackPort[i].setZero();                    } -            if (!_alsaPort[i].isZero()) { -                  midiDriver->unregisterPort(_alsaPort[i]); -                  _alsaPort[i].setZero(); -                  }              }        } @@ -1045,26 +1020,26 @@ void Track::splitPart(Part* part, int tickpos, Part*& p1, Part*& p2)  //   addInRoute  //--------------------------------------------------------- -void Track::addInRoute(const Route& r)   +void Track::addInRoute(const Route& r)        {        if (_inRoutes.indexOf(r) != -1) {              printf("Track::addInRoute: route already there\n");              return;              } -      _inRoutes.push_back(r);  +      _inRoutes.push_back(r);        }  //---------------------------------------------------------  //   addOutRoute  //--------------------------------------------------------- -void Track::addOutRoute(const Route& r)  -      {  +void Track::addOutRoute(const Route& r) +      {        if (_outRoutes.indexOf(r) != -1) {              printf("Track::addOutRoute: route already there\n");              return;              } -      _outRoutes.push_back(r);  +      _outRoutes.push_back(r);        }  //--------------------------------------------------------- diff --git a/muse/muse/track.h b/muse/muse/track.h index 276929c2..ff9dde64 100644 --- a/muse/muse/track.h +++ b/muse/muse/track.h @@ -48,11 +48,6 @@ class MidiOutPort;  class MidiInPort;  class MidiOut; -#ifndef __APPLE__ -// actually it should check for ALSA but I don't know how to do that -typedef struct snd_seq_event snd_seq_event_t; -#endif -  //---------------------------------------------------------  //   ArrangerTrack  //--------------------------------------------------------- @@ -105,7 +100,7 @@ class Track : public QObject {     private:        QString _comment;        PartList* _parts; -      Port _alsaPort[MAX_CHANNELS], _jackPort[MAX_CHANNELS]; +      Port _jackPort[MAX_CHANNELS];        bool _sendSync;   // this port sends mtc/mmc events        int _deviceId;    // midi device id: 0-126; 127 == all @@ -314,12 +309,8 @@ class Track : public QObject {        bool inRouteExists(const Route& r) const;        bool outRouteExists(const Route& r) const; -      Port alsaPort(int channel = 0) const    { return _alsaPort[channel]; }        Port jackPort(int channel = 0) const    { return _jackPort[channel]; } -      void setAlsaPort(const Port& port, int channel = 0) { -            _alsaPort[channel] = port; -            }        void setJackPort(const Port& port, int channel = 0) {              _jackPort[channel] = port;              } diff --git a/muse/synti/CMakeLists.txt b/muse/synti/CMakeLists.txt index 7e5274ac..9954ccd1 100644 --- a/muse/synti/CMakeLists.txt +++ b/muse/synti/CMakeLists.txt @@ -27,7 +27,7 @@ include_directories(     ${PROJECT_SOURCE_DIR}/synti     ) -set (SubDirs libsynti s1 organ deicsonze simpledrums vam mus) +set (SubDirs libsynti s1 organ deicsonze simpledrums vam mus wo)  if (ENABLE_ZYNADDSUBFX)        set (SubDirs ${SubDirs} zynaddsubfx)  | 
