xref: /haiku/headers/os/midi/MidiSynth.h (revision 7120e97489acbf17d86d3f33e3b2e68974fd4b23)
1 
2 #ifndef _MIDI_SYNTH_H
3 #define _MIDI_SYNTH_H
4 
5 #include <BeBuild.h>
6 #include <Midi.h>
7 #include <Synth.h>
8 #include <MidiDefs.h>
9 
10 class BMidiSynth : public BMidi
11 {
12 public:
13 	BMidiSynth();
14 	virtual ~BMidiSynth();
15 
16 	status_t EnableInput(bool enable, bool loadInstruments);
17 	bool IsInputEnabled(void) const;
18 
19 	/* set volume. You can overdrive by passing values larger than 1.0 */
20 	void SetVolume(double volume);
21 	double Volume(void) const;
22 
23 	/* set note offset in semi tones	*/
24 	/* (12 is down an octave, -12 is up an octave) */
25 	void SetTransposition(int16 offset);
26 	int16 Transposition(void) const;
27 
28 	/* Mute and unmute channels (0 to 15) */
29 	void MuteChannel(int16 channel, bool do_mute);
30 	void GetMuteMap(char* pChannels) const;
31 
32 	void SoloChannel(int16 channel, bool do_solo);
33 	void GetSoloMap(char* pChannels) const;
34 
35 	/* Use these functions to drive the synth engine directly */
36 	status_t LoadInstrument(int16 instrument);
37 	status_t UnloadInstrument(int16 instrument);
38 	status_t RemapInstrument(int16 from, int16 to);
39 
40 	void FlushInstrumentCache(bool startStopCache);
41 
42 	/* get current midi tick in microseconds */
43 	uint32 Tick(void) const;
44 
45 	/* The channel variable is 1 to 16. Channel 10 is percussion for example. */
46 	/* The programNumber variable is a number from 0-127 */
47 
48 	virtual void NoteOff(
49 		uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
50 
51 	virtual void NoteOn(
52 		uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
53 
54 	virtual void KeyPressure(
55 		uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
56 
57 	virtual void ControlChange(
58 		uchar channel, uchar controlNumber, uchar controlValue,
59 		uint32 time = B_NOW);
60 
61 	virtual void ProgramChange(
62 		uchar channel, uchar programNumber, uint32 time = B_NOW);
63 
64 	virtual void ChannelPressure(
65 		uchar channel, uchar pressure, uint32 time = B_NOW);
66 
67 	virtual void PitchBend(
68 		uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
69 
70 	virtual void AllNotesOff(bool controlOnly, uint32 time = B_NOW);
71 
72 protected:
73 	void* fSongVariables;
74 	void* fPerformanceVariables;
75 	bool fMidiQueue;
76 
77 private:
78 
79 	virtual void _ReservedMidiSynth1();
80 	virtual void _ReservedMidiSynth2();
81 	virtual void _ReservedMidiSynth3();
82 	virtual void _ReservedMidiSynth4();
83 
84 	friend class BSynth;
85 
86 	virtual void Run();
87 
88 	bool fInputEnabled;
89 	uint32 _reserved[4];
90 };
91 
92 #endif // _MIDI_SYNTH_H
93 
94