File: mididev.cpp

package info (click to toggle)
muse 0.6.3-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,936 kB
  • ctags: 7,446
  • sloc: cpp: 66,262; sh: 8,355; makefile: 755; ansic: 172
file content (107 lines) | stat: -rw-r--r-- 2,376 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//=========================================================
//  MusE
//  Linux Music Editor
//  $Id: mididev.cpp,v 1.1.1.1 2003/10/29 10:06:13 wschweer Exp $
//
//  (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
//=========================================================

#include <config.h>

#include <stdio.h>
#include <unistd.h>
#include <errno.h>

#include "midictrl.h"
#include "song.h"
#include "midi.h"
#include "midiport.h"
#include "mididev.h"
#include "minstrument.h"
#include "config.h"
#include "mpevent.h"

#ifdef MIDI_DRIVER_MIDI_SERIAL
extern void initMidiSerial();
#endif
extern void initMidiAlsa();

MidiDeviceList midiDevices;

//---------------------------------------------------------
//   init
//---------------------------------------------------------

void MidiDevice::init()
      {
      _rwFlags   = 0;
      _masterVol = 16383;
      _port      = -1;
      }

int MidiDevice::rwFlags() const
      {
      return _rwFlags;
      }
void MidiDevice::setrwFlags(int val)
      {
      _rwFlags = val;
      }

//---------------------------------------------------------
//   MidiDevice
//---------------------------------------------------------

MidiDevice::MidiDevice()
      {
      init();
      }

MidiDevice::MidiDevice(const QString& n)
   : _name(n)
      {
      init();
      }

MidiDevice::~MidiDevice()
      {
      }

//---------------------------------------------------------
//   setMasterVol
//---------------------------------------------------------

void MidiDevice::setMasterVol(int val)
      {
      _masterVol = val;
      unsigned char data[6] = { 0x7f, 0x7f, 0x04, 0x01, 0x00, 0x00 };
      data[4] = val & 0x7f;
      data[5] = (val >> 7) & 0x7f;
      MidiPlayEvent event(0, data, 6);
      putEvent(&event);
      }

//---------------------------------------------------------
//   find
//---------------------------------------------------------

MidiDevice* MidiDeviceList::find(const QString& s)
      {
      for (iMidiDevice i = begin(); i != end(); ++i)
            if ((*i)->name() == s)
                  return *i;
      return 0;
      }

//---------------------------------------------------------
//   initMidiDevices
//---------------------------------------------------------

void initMidiDevices()
      {
#ifdef MIDI_DRIVER_MIDI_SERIAL
      initMidiSerial();
#endif
      initMidiAlsa();
      }