~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to driver/midirawdev.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//=========================================================
2
2
//  MusE
3
3
//  Linux Music Editor
4
 
//    $Id: midirawdev.cpp,v 1.2 2002/02/07 08:14:48 muse Exp $
 
4
//    $Id: midirawdev.cpp,v 1.1.1.1 2003/10/29 10:06:11 wschweer Exp $
5
5
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
6
6
//=========================================================
7
7
 
8
8
#include "midirawdev.h"
9
9
#include "globals.h"
10
10
#include "event.h"
 
11
#include "mpevent.h"
11
12
#include "midictrl.h"
12
13
 
13
14
#include <stdio.h>
54
55
                  fprintf(stderr, "midi write error: %s\n", strerror(errno));
55
56
                  exit(-1);
56
57
                  }
 
58
            if (nn != n) {
 
59
                  fprintf(stderr, "midi write: written %d from %d\n", nn, n);
 
60
                  }
57
61
            rp += nn;
58
62
            }
59
63
      else {
60
64
            int n = iobuffer + IO_BUFFERSIZE - rp;
 
65
 
61
66
            int nn = write(rp, n);
62
67
            if (nn < 0) {
63
68
                  fprintf(stderr, "midi write error: %s\n", strerror(errno));
64
69
                  exit(-1);
65
70
                  }
 
71
            if (nn != n) {
 
72
                  fprintf(stderr, "midi write: written %d from %d\n", nn, n);
 
73
                  }
66
74
            rp += nn;
67
75
            if (nn == n) {
68
76
                  int n  = wp - iobuffer;
71
79
                        fprintf(stderr, "midi write error: %s\n", strerror(errno));
72
80
                        exit(-1);
73
81
                        }
 
82
                  if (nn != n) {
 
83
                        fprintf(stderr, "midi write: written %d from %d\n", nn, n);
 
84
                        }
74
85
                  rp = iobuffer + nn;
75
86
                  }
76
87
            }
113
124
 
114
125
void MidiRawDevice::putClock()
115
126
      {
116
 
      put(0xf8);        // no lock necessary
 
127
      put(0xf8);
117
128
      flush();
118
129
      }
119
130
 
123
134
 
124
135
void MidiRawDevice::putStart()
125
136
      {
126
 
      put(0xfa);        // no lock necessary
 
137
      put(0xfa);
127
138
      flush();
128
139
      }
129
140
 
133
144
 
134
145
void MidiRawDevice::putStop()
135
146
      {
136
 
      put(0xfc);        // no lock necessary
 
147
      put(0xfc);
137
148
      flush();
138
149
      }
139
150
 
143
154
 
144
155
void MidiRawDevice::putContinue()
145
156
      {
146
 
      put(0xfb);        // no lock necessary
 
157
      put(0xfb);
147
158
      flush();
148
159
      }
149
160
 
163
174
//   putEvent
164
175
//---------------------------------------------------------
165
176
 
166
 
void MidiRawDevice::putEvent(const MidiEvent* e)
 
177
void MidiRawDevice::putEvent(const MidiPlayEvent* e)
167
178
      {
168
179
      int chn = e->channel();
169
180
      int a = e->dataA();
170
181
      int b = e->dataB();
171
 
      int c = e->dataC();
172
 
      switch(e->type()) {
173
 
            case MidiEvent::Note:
174
 
                  chnEvent2(chn, 0x90, a, b);
175
 
                  break;
176
 
            case MidiEvent::NoteOff:
177
 
                  chnEvent2(chn, 0x80, a, b);
178
 
                  break;
179
 
            case MidiEvent::Program:
180
 
                  chnEvent1(chn, 0xc0, a);
181
 
                  break;
182
 
            case MidiEvent::Ctrl7:
183
 
                  chnEvent2(chn, 0xb0, a, b);
184
 
                  break;
185
 
            case MidiEvent::Ctrl14:
186
 
                  chnEvent2(chn, 0xb0, a, b & 0x7f);
187
 
                  chnEvent2(chn, 0xb0, a >> 7, b >> 7);
188
 
                  break;
189
 
            case MidiEvent::RPN:
190
 
                  chnEvent2(chn, 0xb0, CTRL_LDATA, b & 0x7f);
191
 
                  chnEvent2(chn, 0xb0, CTRL_HDATA, b >> 7);
192
 
                  chnEvent2(chn, 0xb0, CTRL_LRPN, a & 0x7f);
193
 
                  chnEvent2(chn, 0xb0, CTRL_HRPN, a >> 7);
194
 
                  break;
195
 
            case MidiEvent::NRPN:
196
 
                  chnEvent2(chn, 0xb0, CTRL_LDATA, b & 0x7f);
197
 
                  chnEvent2(chn, 0xb0, CTRL_HDATA, b >> 7);
198
 
                  chnEvent2(chn, 0xb0, CTRL_LNRPN, a & 0x7f);
199
 
                  chnEvent2(chn, 0xb0, CTRL_HNRPN, a >> 7);
200
 
                  break;
201
 
            case MidiEvent::Pitch:
202
 
                  {
203
 
                  int lval = (a - 8192) & 0x7f;
204
 
                  int hval = ((a - 8192) >> 7) & 0x7f;
205
 
                  chnEvent2(chn, 0xe0, lval, hval);
206
 
                  }
207
 
                  break;
208
 
            case MidiEvent::PAfter:
209
 
                  chnEvent2(chn, 0xa0, a, b);
210
 
                  break;
211
 
            case MidiEvent::CAfter:
212
 
                  chnEvent1(chn, 0xd0, a);
213
 
                  break;
214
 
            case MidiEvent::Sysex:
 
182
      int typ = e->type();
 
183
 
 
184
      switch(typ) {
 
185
            case 0x90:
 
186
            case 0x80:
 
187
            case 0xb0:
 
188
            case 0xa0:
 
189
            case 0xe0:
 
190
                  chnEvent2(chn, typ, a, b);
 
191
                  break;
 
192
            case 0xc0:
 
193
            case 0xd0:
 
194
                  chnEvent1(chn, typ, a);
 
195
                  break;
 
196
            case 0xf0:
215
197
                  {
216
198
                  const unsigned char* data = e->data();
217
 
                  int n = e->dataLen();
 
199
                  int n = e->len();
218
200
                  runState = 0;
219
201
                  put(0xf0);
220
202
                  while (n--)
275
257
 
276
258
void MidiRawDevice::sysexReceived(const unsigned char* p, int n)
277
259
      {
278
 
      MidiEvent* event = new MidiEvent(port(), 0, 0, MidiEvent::Sysex, n, p);
 
260
      MidiPlayEvent* event = new MidiPlayEvent(port(), p, n);
279
261
      midiThread->eventReceived(event);
280
262
      }
281
263