midimapper.h

00001 /*  midimapper.h  - The midi mapper object
00002     This file is part of LibKMid 0.9.5
00003     Copyright (C) 1997,98,99,2000  Antonio Larrosa Jimenez
00004     LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010  
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015  
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 
00021     Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
00022 
00023 ***************************************************************************/
00024 #ifndef _MIDIMAPPER_H
00025 #define _MIDIMAPPER_H
00026 
00027 #include <stdio.h>
00028 #include <libkmid/dattypes.h>
00029 #include <kdelibs_export.h>
00030 
00031 #define KM_NAME_SIZE 30
00032 
00059 class KMID_EXPORT MidiMapper
00060 {
00061   private:
00062     class MidiMapperPrivate;
00063     MidiMapperPrivate *d;
00064 
00069     struct Keymap
00070     {
00071       char name[KM_NAME_SIZE];
00072       uchar key[128];
00073       struct Keymap *next;
00074     };
00075 
00076     int _ok;
00077 
00078     uchar   channelmap[16]; 
00085     Keymap *channelKeymap[16]; 
00086 
00092     int channelPatchForced[16]; 
00093 
00094     uchar   patchmap[128];
00095 
00100     Keymap *patchKeymap[128];
00101 
00106     Keymap *keymaps; 
00107 
00112     char *_filename; 
00113 
00118     int mapExpressionToVolumeEvents; 
00119 
00124     int mapPitchBender;
00125 
00133     int pitchBenderRatio; 
00134 
00135     void getValue(char *s,char *v);
00136     void removeSpaces(char *s);
00137     int  countWords(char *s);
00138     void getWord(char *t,char *s,int w); 
00139     // get from s the word in position  w and store it in t
00140 
00141     void deallocateMaps(void);
00142     Keymap *createKeymap(char *name,uchar use_same_note=0,uchar note=0);
00143     void readPatchmap(FILE *fh);
00144     void readKeymap(FILE *fh,char *first_line);
00145     void readChannelmap(FILE *fh);
00146     void readOptions(FILE *fh);
00147 
00148     void addKeymap(Keymap *newkm);
00149     Keymap *keymap(char *n);
00150 
00151   public:
00156     MidiMapper(const char *name);
00157 
00161     ~MidiMapper();
00162 
00167     void loadFile(const char *name);    
00168 
00172     int  ok(void) { return _ok; }
00173 
00177     uchar channel(uchar chn) { return channelmap[chn];}
00178 
00182     uchar patch(uchar chn,uchar pgm);
00183 
00188     uchar key(uchar chn,uchar pgm, uchar note);
00189 
00194     void  pitchBender(uchar chn,uchar &lsb,uchar &msb);
00195 
00200     void  controller(uchar chn,uchar &ctl,uchar &v);
00201 
00206     const char *filename(void);
00207 
00208 };
00209 
00210 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys