1
/**************************************************************************
3
midistat.cc - class MidiStatus, change it internally and then send it.
4
Copyright (C) 1997,98,99 Antonio Larrosa Jimenez
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
Send comments and bug fixes to antlarr@arrakis.es
21
or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
23
***************************************************************************/
25
#include "deviceman.h"
27
#include "../version.h"
29
extern int MT32toGM[128];
31
MidiStatus::MidiStatus()
35
for (int chn=0;chn<N_CHANNELS;chn++)
38
chn_bender[chn]=0x4000;
39
chn_pressure[chn]=127;
41
chn_controller[chn][i]=0;
42
chn_controller[chn][CTL_MAIN_VOLUME]=127;
43
chn_controller[chn][11]=127;
44
chn_controller[chn][0x4a]=127;
45
chn_lastisvolumeev[chn]=1;
51
MidiStatus::~MidiStatus()
55
// void noteOn ( uchar chn, uchar note, uchar vel );
56
// void noteOff ( uchar chn, uchar note, uchar vel );
58
void MidiStatus::chnPatchChange ( uchar chn, uchar patch )
63
void MidiStatus::chnPressure ( uchar chn, uchar vel )
65
chn_pressure[chn]=vel;
68
void MidiStatus::chnPitchBender ( uchar chn, uchar lsb, uchar msb )
70
chn_bender[chn]=((int)msb<<8|lsb);
73
void MidiStatus::chnController ( uchar chn, uchar ctl , uchar v )
75
if (ctl==7) chn_lastisvolumeev[chn]=1;
76
else if (ctl==11) chn_lastisvolumeev[chn]=0;
78
chn_controller[chn][ctl]=v;
81
void MidiStatus::tmrSetTempo(int v)
86
void MidiStatus::sendData(DeviceManager *midi,int gm)
88
for (int chn=0;chn<N_CHANNELS;chn++)
91
printf("Restoring channel %d\n",chn);
93
midi->chnPatchChange(chn,
94
(gm==1)?(chn_patch[chn]):(MT32toGM[chn_patch[chn]]));
95
midi->chnPitchBender(chn,chn_bender[chn]&0xFF,chn_bender[chn]>>8);
96
midi->chnPressure(chn,chn_pressure[chn]);
97
if (chn_lastisvolumeev[chn])
99
midi->chnController(chn,11,chn_controller[chn][11]);
100
midi->chnController(chn,CTL_MAIN_VOLUME,chn_controller[chn][CTL_MAIN_VOLUME]);
102
midi->chnController(chn,CTL_MAIN_VOLUME,chn_controller[chn][CTL_MAIN_VOLUME]);
103
midi->chnController(chn,11,chn_controller[chn][11]);
106
for (int i=0;i<N_CTL;i++)
107
midi->chnController(chn,i,chn_controller[chn][i]);
110
midi->tmrSetTempo(tempo);