some missing midi headers

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1684 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper 2002-10-26 18:51:58 +00:00
parent 5cdacbaabb
commit 4b8670624a
5 changed files with 536 additions and 0 deletions

118
headers/os/midi/MidiPort.h Normal file
View File

@ -0,0 +1,118 @@
/*******************************************************************************
/
/ File: MidiPort.h
/
/ Description: Interface to MIDI hardware ports.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MIDI_PORT_H
#define _MIDI_PORT_H
#include <Midi.h>
class BMidiLocalProducer;
class BMidiPortConsumer;
/*------------------------------------------------------------*/
class BMidiPort : public BMidi {
public:
BMidiPort(const char *name=NULL);
~BMidiPort();
status_t InitCheck() const;
status_t Open(const char *name);
void Close();
const char * PortName() const;
virtual void NoteOff(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void NoteOn(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void KeyPressure(uchar channel,
uchar note,
uchar pressure,
uint32 time = B_NOW);
virtual void ControlChange(uchar channel,
uchar controlNumber,
uchar controlValue,
uint32 time = B_NOW);
virtual void ProgramChange(uchar channel,
uchar programNumber,
uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel,
uchar pressure,
uint32 time = B_NOW);
virtual void PitchBend(uchar channel,
uchar lsb,
uchar msb,
uint32 time = B_NOW);
virtual void SystemExclusive(void* data,
size_t dataLength,
uint32 time = B_NOW);
virtual void SystemCommon(uchar statusByte,
uchar data1,
uchar data2,
uint32 time = B_NOW);
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
virtual status_t Start();
virtual void Stop();
int32 CountDevices();
status_t GetDeviceName(int32 n, char * name,
size_t bufSize = B_OS_NAME_LENGTH);
private:
typedef BMidi _inherited;
virtual void _ReservedMidiPort1();
virtual void _ReservedMidiPort2();
virtual void _ReservedMidiPort3();
virtual void Run();
friend class BMidiPortConsumer;
void Dispatch(const unsigned char * buffer, size_t size, bigtime_t when);
ssize_t Read(void *buffer, size_t numBytes) const;
ssize_t Write(void *buffer, size_t numBytes, uint32 time) const;
void ScanDevices();
BMidiProducer *remote_source;
BMidiConsumer *remote_sink;
char* fName;
status_t fCStatus;
BList * _fDevices;
uint8 _m_prev_cmd;
bool _m_enhanced;
uint8 _m_reserved[2];
// used to glue us to the new midi kit
BMidiLocalProducer *local_source;
BMidiPortConsumer *local_sink;
};
/*------------------------------------------------------------*/
#endif

115
headers/os/midi/MidiSynth.h Normal file
View File

@ -0,0 +1,115 @@
/*******************************************************************************
/
/ File: MidiSynth.h
/
/ Description: Midi object that talks to the General MIDI synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MIDI_SYNTH_H
#define _MIDI_SYNTH_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <Midi.h>
#include <Synth.h>
#include <MidiDefs.h>
class BMidiSynth : public BMidi
{
public:
BMidiSynth();
virtual ~BMidiSynth();
status_t EnableInput(bool enable, bool loadInstruments);
bool IsInputEnabled(void) const;
/* set volume. You can overdrive by passing values larger than 1.0*/
void SetVolume(double volume);
double Volume(void) const;
/* set note offset in semi tones */
/* (12 is down an octave, -12 is up an octave)*/
void SetTransposition(int16 offset);
int16 Transposition(void) const;
/* Mute and unmute channels (0 to 15)*/
void MuteChannel(int16 channel, bool do_mute);
void GetMuteMap(char *pChannels) const;
void SoloChannel(int16 channel, bool do_solo);
void GetSoloMap(char *pChannels) const;
/* Use these functions to drive the synth engine directly*/
status_t LoadInstrument(int16 instrument);
status_t UnloadInstrument(int16 instrument);
status_t RemapInstrument(int16 from, int16 to);
void FlushInstrumentCache(bool startStopCache);
/* get current midi tick in microseconds*/
uint32 Tick(void) const;
/* The channel variable is 1 to 16. Channel 10 is percussion for example.*/
/* The programNumber variable is a number from 0-127*/
virtual void NoteOff(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void NoteOn(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void KeyPressure(uchar channel,
uchar note,
uchar pressure,
uint32 time = B_NOW);
virtual void ControlChange(uchar channel,
uchar controlNumber,
uchar controlValue,
uint32 time = B_NOW);
virtual void ProgramChange(uchar channel,
uchar programNumber,
uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel,
uchar pressure,
uint32 time = B_NOW);
virtual void PitchBend(uchar channel,
uchar lsb,
uchar msb,
uint32 time = B_NOW);
virtual void AllNotesOff(bool controlOnly, uint32 time = B_NOW);
protected:
void* fSongVariables;
void* fPerformanceVariables;
bool fMidiQueue;
private:
virtual void _ReservedMidiSynth1();
virtual void _ReservedMidiSynth2();
virtual void _ReservedMidiSynth3();
virtual void _ReservedMidiSynth4();
friend class BSynth;
virtual void Run();
bool fInputEnabled;
uint32 _reserved[4];
};
#endif

View File

@ -0,0 +1,86 @@
/*******************************************************************************
/
/ File: MidiSynthFile.h
/
/ Description: Send a MIDI file to the synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MIDI_SYNTH_FILE_H
#define _MIDI_SYNTH_FILE_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <MidiSynth.h>
#include <Entry.h>
typedef void (*synth_file_hook)(int32 arg);
class BMidiSynthFile : public BMidiSynth
{
public:
BMidiSynthFile();
~BMidiSynthFile();
status_t LoadFile(const entry_ref *midi_entry_ref);
void UnloadFile(void);
virtual status_t Start(void);
virtual void Stop(void);
void Fade(void);
void Pause(void);
void Resume(void);
/* get ticks in microseconds of length of song*/
int32 Duration(void) const;
/* set the current playback position of song in microseconds*/
int32 Position(int32 ticks) const;
/* get the current playback position of a song in microseconds*/
int32 Seek();
/* get the patches required to play this song*/
status_t GetPatches(int16 *pArray768, int16 *pReturnedCount) const;
/* Set a call back when song is done*/
void SetFileHook(synth_file_hook pSongHook, int32 arg);
/* poll to see if song is done*/
bool IsFinished(void) const;
/* set song master tempo. (1.0 uses songs encoded tempo, 2.0 will play*/
/* song twice as fast, and 0.5 will play song half as fast*/
void ScaleTempoBy(double tempoFactor);
/* sets tempo in beats per minute*/
void SetTempo(int32 newTempoBPM);
/* returns tempo in beats per minute*/
int32 Tempo(void) const;
/* pass true to loop song, false to not loop*/
void EnableLooping(bool loop);
/* Mute and unmute tracks (0 to 64)*/
void MuteTrack(int16 track, bool do_mute);
void GetMuteMap(char *pTracks) const;
void SoloTrack(int16 track, bool do_solo);
void GetSoloMap(char *pTracks) const;
private:
virtual void _ReservedMidiSynthFile1();
virtual void _ReservedMidiSynthFile2();
virtual void _ReservedMidiSynthFile3();
friend class BSynth;
uint32 _reserved[4];
};
#endif

76
headers/os/midi/Samples.h Normal file
View File

@ -0,0 +1,76 @@
/*******************************************************************************
/
/ File: Samples.h
/
/ Description: Sound effects.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _SAMPLES_H
#define _SAMPLES_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <Entry.h>
typedef void (*sample_exit_hook)(int32 arg);
typedef bool (*sample_loop_hook)(int32 arg);
class BSamples
{
public:
BSamples();
virtual ~BSamples();
/* start a sample playing*/
void Start(void * sampleData, /* pointer to audio data*/
int32 frames, /* number of frames*/
int16 bytes_per_sample, /* btyes per sample 1 or 2*/
int16 channel_count, /* mono or stereo 1 or 2*/
double pitch, /* floating sample rate*/
int32 loopStart, /* loop start in frames*/
int32 loopEnd, /* loop end in frames*/
double sampleVolume, /* sample volume*/
double stereoPosition, /* stereo placement*/
int32 hook_arg, /* hook argument*/
sample_loop_hook pLoopContinueProc,
sample_exit_hook pDoneProc);
/* currently paused*/
bool IsPaused(void) const;
void Pause(void);
void Resume(void);
void Stop(void);
bool IsPlaying(void) const;
void SetVolume(double newVolume);
double Volume(void) const;
void SetSamplingRate(double newRate);
double SamplingRate(void) const;
void SetPlacement(double stereoPosition);
/* Set the stereo position (-1.0 left to +1.0 right, 0 is middle)*/
double Placement(void) const;
/* Enable/Disable reverb on this particular IgorSound*/
void EnableReverb(bool useReverb);
private:
virtual void _ReservedSamples1();
virtual void _ReservedSamples2();
virtual void _ReservedSamples3();
int32 fReference;
double fPauseVariable;
void* fFileVariables;
uint32 _reserved[4];
};
#endif

141
headers/os/midi/Synth.h Normal file
View File

@ -0,0 +1,141 @@
/*******************************************************************************
/
/ File: Synth.h
/
/ Description: Interface to the General MIDI synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _SYNTH_H
#define _SYNTH_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <Entry.h>
#include <MidiDefs.h>
#include <OS.h>
typedef enum interpolation_mode
{
B_DROP_SAMPLE = 0,
B_2_POINT_INTERPOLATION,
B_LINEAR_INTERPOLATION
} interpolation_mode;
typedef enum reverb_mode
{
B_REVERB_NONE = 1,
B_REVERB_CLOSET,
B_REVERB_GARAGE,
B_REVERB_BALLROOM,
B_REVERB_CAVERN,
B_REVERB_DUNGEON
} reverb_mode;
typedef void (*synth_controller_hook) (int16 channel,
int16 controller,
int16 value);
class BMidiSynth;
class BMidiSynthFile;
class BSynth
{
public:
BSynth();
BSynth(synth_mode synth);
#if !_PR3_COMPATIBLE_
virtual ~BSynth();
#else
~BSynth();
#endif
status_t LoadSynthData(entry_ref *instrumentsFile);
status_t LoadSynthData(synth_mode synth);
synth_mode SynthMode(void);
void Unload(void);
bool IsLoaded(void) const;
/* change audio modes*/
status_t SetSamplingRate(int32 sample_rate);
int32 SamplingRate() const;
status_t SetInterpolation(interpolation_mode interp_mode);
interpolation_mode Interpolation() const;
void SetReverb(reverb_mode rev_mode);
reverb_mode Reverb() const;
status_t EnableReverb(bool reverb_enabled);
bool IsReverbEnabled() const;
/* change voice allocation*/
status_t SetVoiceLimits(int16 maxSynthVoices,
int16 maxSampleVoices,
int16 limiterThreshhold);
int16 MaxSynthVoices(void) const;
int16 MaxSampleVoices(void) const;
int16 LimiterThreshhold(void) const;
/* get and set the master mix volume. A volume level of 1.0*/
/* is normal, and volume level of 4.0 will overdrive 4 times*/
void SetSynthVolume(double theVolume);
double SynthVolume(void) const;
void SetSampleVolume(double theVolume);
double SampleVolume(void) const;
/* display feedback information*/
/* This will return the number of 16-bit samples stored into the pLeft*/
/* and pRight arrays. Usually 1024. This returns the current data*/
/* points being sent to the hardware.*/
status_t GetAudio(int16 *pLeft, int16 *pRight,
int32 max_samples) const;
/* disengage from audio output streams*/
void Pause(void);
/* reengage to audio output streams*/
void Resume(void);
/* Set a call back on controller events*/
void SetControllerHook(int16 controller,
synth_controller_hook cback);
int32 CountClients(void) const;
private:
virtual void _ReservedSynth1();
virtual void _ReservedSynth2();
virtual void _ReservedSynth3();
virtual void _ReservedSynth4();
friend BMidiSynth;
friend BMidiSynthFile;
int32 fClientCount;
void _init();
status_t _do_load(synth_mode synth);
status_t _load_insts(entry_ref *ref);
synth_mode fMode;
int16 fMaxSynthVox;
int16 fMaxSampleVox;
int16 fLimiter;
int32 fSRate;
interpolation_mode fInterp;
int32 fModifiers;
reverb_mode fReverb;
sem_id fSetupLock;
uint32 _reserved[4];
};
extern _IMPEXP_MIDI BSynth *be_synth;
#endif