~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to arts/midi/midisend.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright (C) 1999 Emmeran Seehuber
 
4
                   the_emmy@gmx.de
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
19
 
 
20
*/
 
21
#ifndef MIDISEND_H
 
22
#define MIDISEND_H
 
23
 
 
24
#include <stdio.h>
 
25
#include <stdlib.h>
 
26
#include <string.h>
 
27
#include <unistd.h>
 
28
#include <fcntl.h>
 
29
 
 
30
#include "artsmidi.h"
 
31
#include <vector>
 
32
#include <iostream>
 
33
#include <string>
 
34
 
 
35
extern "C" 
 
36
{
 
37
#include "midimsg.h"
 
38
}
 
39
 
 
40
/*
 
41
  This class does the mapping of the
 
42
  channels and pitches
 
43
*/
 
44
class CMidiMap {
 
45
public:
 
46
  /*
 
47
    Reads in the mapfile pszFileName.
 
48
    Returns TRUE, if successfull.
 
49
  */
 
50
  bool readMap(const char* pszFileName);
 
51
  /*
 
52
    Maps the given message according to 
 
53
    the actual read configuration.
 
54
  */
 
55
  void mapMsg(Byte* msg);
 
56
 
 
57
private:
 
58
  /*
 
59
    Parses a configuration line.
 
60
  */
 
61
  void parseLine(char* pszLine, const char* pszConfigFile, int nConfigLine );
 
62
 
 
63
  /*
 
64
    Gets the next word out of the line. throws
 
65
    the exception CEOutOfLine, if there is no 
 
66
    more word in the line.
 
67
 
 
68
    A word consists of all but \0, spacecharacter, ';' and
 
69
    ','
 
70
    
 
71
    pszLine is the pointer to the start of the
 
72
    line. This function modifies the pointer.
 
73
    pszWord is the pointer to the found word.
 
74
  */
 
75
  bool getNextWord(char*& pszLine, char*& pszWord);
 
76
private:
 
77
 
 
78
  /*
 
79
    For each channel one instance of this structure
 
80
    exists in the channelMaps. It holds the mapping information
 
81
    for nChannel.
 
82
  */
 
83
  struct ChannelMaps {
 
84
    int nChannel;
 
85
 
 
86
    struct ChannelRemap {
 
87
      int nPitch;
 
88
      int nChannel;
 
89
    };
 
90
 
 
91
    struct PitchRemap {
 
92
      int nPitch;
 
93
      int nToPitch;
 
94
    };
 
95
 
 
96
    typedef std::map<int,ChannelRemap> ChannelRemapMap;
 
97
    ChannelRemapMap channelRemaps;
 
98
    typedef std::map<int,PitchRemap> PitchRemapMap;
 
99
    PitchRemapMap pitchRemaps;
 
100
  };
 
101
  typedef std::map<int,ChannelMaps> ChannelMapsMap;
 
102
  ChannelMapsMap channelMaps;
 
103
};
 
104
 
 
105
 
 
106
#endif