~keithsalisbury/mixxx/mixxx

« back to all changes in this revision

Viewing changes to mixxx/src/midi/midideviceportmidi.h

  • Committer: Keith Salisbury
  • Date: 2012-05-06 13:44:20 UTC
  • mfrom: (2994.1.100 mixxx-trunk)
  • Revision ID: keithsalisbury@gmail.com-20120506134420-8k1dqq10aqmx0ecq
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
  * @file midideviceportmidi.h
3
 
  * @author Albert Santoni alberts@mixxx.org
4
 
  * @date Thu Dec 18 2008
5
 
  * @brief PortMidi-based MIDI backend
6
 
  *
7
 
  */
8
 
 
9
 
/***************************************************************************
10
 
 *                                                                         *
11
 
 *   This program is free software; you can redistribute it and/or modify  *
12
 
 *   it under the terms of the GNU General Public License as published by  *
13
 
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 
 *   (at your option) any later version.                                   *
15
 
 *                                                                         *
16
 
 ***************************************************************************/
17
 
 
18
 
#ifndef MIDIDEVICEPORTMIDI_H
19
 
#define MIDIDEVICEPORTMIDI_H
20
 
 
21
 
#include <portmidi.h>
22
 
#include <porttime.h>
23
 
#include <QtCore>
24
 
#include "mididevice.h"
25
 
 
26
 
#define MIXXX_PORTMIDI_BUFFER_LEN 64 /**Number of MIDI messages to buffer*/
27
 
#define MIXXX_PORTMIDI_NO_DEVICE_STRING "None" /**String to display for no MIDI devices present */
28
 
/**
29
 
  *@author Albert Santoni
30
 
  */
31
 
 
32
 
/** A PortMidi-based implementation of MidiDevice */
33
 
class MidiDevicePortMidi : public MidiDevice {
34
 
public:
35
 
    MidiDevicePortMidi(MidiMapping* mapping, 
36
 
                       const PmDeviceInfo* inputDeviceInfo, 
37
 
                       const PmDeviceInfo* outputDeviceInfo, 
38
 
                       int inputDeviceIndex,
39
 
                       int outputDeviceIndex);
40
 
    ~MidiDevicePortMidi();
41
 
    int open();
42
 
    int close();
43
 
    void sendShortMsg(unsigned int word);
44
 
    void sendSysexMsg(unsigned char data[], unsigned int length);
45
 
protected:
46
 
    void run();
47
 
    const PmDeviceInfo* m_pInputDeviceInfo;
48
 
    const PmDeviceInfo* m_pOutputDeviceInfo;
49
 
    int m_iInputDeviceIndex;
50
 
    int m_iOutputDeviceIndex;
51
 
    PortMidiStream *m_pInputStream;
52
 
    PortMidiStream *m_pOutputStream;
53
 
    PmEvent m_midiBuffer[MIXXX_PORTMIDI_BUFFER_LEN];
54
 
    static QList<QString> m_deviceList;
55
 
    QMutex m_mutex;         /** Protects access to this object. Makes it thread safe. */
56
 
    static QMutex m_sPMLock;    // PortMidi is not thread-safe, so we need to only allow one thread at a time
57
 
    bool m_bStopRequested;
58
 
};
59
 
 
60
 
#endif