MuseScore  3.4
Music composition and notation
jackaudio.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Linux Music Score Editor
4 //
5 // Copyright (C) 2002-2009 Werner Schweer and others
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19 
20 #ifndef __JACKAUDIO_H__
21 #define __JACKAUDIO_H__
22 
23 #include "config.h"
24 #include "driver.h"
25 #include <jack/jack.h>
26 
27 namespace Ms {
28 
29 class Synth;
30 class Seq;
31 class MidiDriver;
32 
33 //---------------------------------------------------------
34 // JackAudio
35 //---------------------------------------------------------
36 
37 class JackAudio : public Driver {
38  unsigned _segmentSize;
39  // We use fakeState if preferences.useJackTransport = false to emulate JACK Transport.
40  // ALSA, PortAudio do the same thing because of they don't have any transport.
41  // Also this implements fake transport when we have to temporarily disconnect from JACK Transport.
42  // It may be useful when playing count in to let JACK Transport wait before playing score.
44 
45  jack_client_t* client;
46  char _jackName[8];
47 
49  QList<jack_port_t*> ports;
50  QList<jack_port_t*> midiOutputPorts;
51  QList<jack_port_t*> midiInputPorts;
52 
53  static int processAudio(jack_nframes_t, void*);
54  static void timebase (jack_transport_state_t, jack_nframes_t, jack_position_t*, int, void *);
55  void hotPlug();
56  void setTimebaseCallback();
62  QList<QString> inputPorts();
63  public:
64  JackAudio(Seq*);
65  virtual ~JackAudio();
66  virtual bool init(bool hot = false);
67  virtual bool start(bool hotPlug = false);
68  virtual bool stop();
69  int framePos() const;
70  void connect(void*, void*);
71  void connect(const char* src, const char* dst);
72  void disconnect(void* src, void* dst);
73  virtual bool isRealtime() const { return jack_is_realtime(client); }
74  virtual void startTransport();
75  virtual void stopTransport();
76  virtual Transport getState() override;
77  virtual void seekTransport(int);
78  virtual int sampleRate() const { return jack_get_sample_rate(client); }
79  virtual void putEvent(const NPlayEvent&, unsigned framePos);
80  virtual void midiRead();
81 
82  virtual void registerPort(const QString& name, bool input, bool midi);
83  virtual void unregisterPort(jack_port_t*);
84  virtual void handleTimeSigTempoChanged();
85  virtual void checkTransportSeek(int, int, bool);
86  virtual int bufferSize() {return _segmentSize;}
87  void setBufferSize(int nframes) { _segmentSize = nframes;}
88  void updateOutPortCount(int);
89  };
90 
91 
92 } // namespace Ms
93 #endif
94 
static int processAudio(jack_nframes_t, void *)
Definition: jackaudio.cpp:354
virtual void putEvent(const NPlayEvent &, unsigned framePos)
Definition: jackaudio.cpp:556
JackAudio(Seq *)
Definition: jackaudio.cpp:48
virtual void unregisterPort(jack_port_t *)
Definition: jackaudio.cpp:128
bool timeSigTempoChanged
Definition: jackaudio.h:48
unsigned _segmentSize
Definition: jackaudio.h:38
jack_client_t * client
Definition: jackaudio.h:45
QList< QString > inputPorts()
Definition: jackaudio.cpp:142
Transport fakeState
Definition: jackaudio.h:43
void setTimebaseCallback()
Definition: jackaudio.cpp:743
virtual Transport getState() override
Definition: jackaudio.cpp:537
Definition: driver.h:33
static void timebase(jack_transport_state_t, jack_nframes_t, jack_position_t *, int, void *)
Definition: jackaudio.cpp:317
virtual void startTransport()
Definition: jackaudio.cpp:513
Transport
Definition: seq.h:92
void restoreMidiConnections()
Definition: jackaudio.cpp:900
Definition: seq.h:104
virtual bool start(bool hotPlug=false)
Definition: jackaudio.cpp:218
virtual int bufferSize()
Definition: jackaudio.h:86
QList< jack_port_t * > midiOutputPorts
Definition: jackaudio.h:50
virtual ~JackAudio()
Definition: jackaudio.cpp:58
Definition: jackaudio.h:37
void connect(void *, void *)
Definition: jackaudio.cpp:165
int framePos() const
Definition: jackaudio.cpp:266
virtual bool init(bool hot=false)
Definition: jackaudio.cpp:460
virtual void seekTransport(int)
Definition: jackaudio.cpp:732
Definition: aeolus.cpp:26
virtual void checkTransportSeek(int, int, bool)
Definition: jackaudio.cpp:684
void rememberAudioConnections()
Definition: jackaudio.cpp:773
void hotPlug()
Definition: jackaudio.cpp:940
Definition: event.h:238
void rememberMidiConnections()
Definition: jackaudio.cpp:853
void releaseTimebaseCallback()
Definition: jackaudio.cpp:760
virtual int sampleRate() const
Definition: jackaudio.h:78
void restoreAudioConnections()
Definition: jackaudio.cpp:805
virtual void stopTransport()
Definition: jackaudio.cpp:525
void setBufferSize(int nframes)
Definition: jackaudio.h:87
virtual void midiRead()
Definition: jackaudio.cpp:662
virtual bool isRealtime() const
Definition: jackaudio.h:73
virtual void registerPort(const QString &name, bool input, bool midi)
Definition: jackaudio.cpp:104
void disconnect(void *src, void *dst)
Definition: jackaudio.cpp:200
virtual bool stop()
Definition: jackaudio.cpp:248
QList< jack_port_t * > ports
Definition: jackaudio.h:49
void updateOutPortCount(int)
Definition: jackaudio.cpp:74
virtual void handleTimeSigTempoChanged()
Definition: jackaudio.cpp:673
QList< jack_port_t * > midiInputPorts
Definition: jackaudio.h:51
char _jackName[8]
Definition: jackaudio.h:46