1 /***************************************************************************** 2 ** $Source: /cygdrive/d/Private/_SVNROOT/bluemsx/blueMSX/Src/SoundChips/AudioMixer.h,v $ 3 ** 4 ** $Revision: 1.14 $ 5 ** 6 ** $Date: 2009-07-03 21:27:14 $ 7 ** 8 ** More info: http://www.bluemsx.com 9 ** 10 ** Copyright (C) 2003-2006 Daniel Vik 11 ** 12 ** This program is free software; you can redistribute it and/or modify 13 ** it under the terms of the GNU General Public License as published by 14 ** the Free Software Foundation; either version 2 of the License, or 15 ** (at your option) any later version. 16 ** 17 ** This program is distributed in the hope that it will be useful, 18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 ** GNU General Public License for more details. 21 ** 22 ** You should have received a copy of the GNU General Public License 23 ** along with this program; if not, write to the Free Software 24 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 ** 26 ****************************************************************************** 27 */ 28 #ifndef AUDIO_MIXER_H 29 #define AUDIO_MIXER_H 30 31 #include "MsxTypes.h" 32 33 /* Type definitions */ 34 typedef struct Mixer Mixer; 35 36 #define AUDIO_MONO_BUFFER_SIZE 10000 37 #define AUDIO_STEREO_BUFFER_SIZE (2 * AUDIO_MONO_BUFFER_SIZE) 38 39 #define AUDIO_SAMPLERATE 44100 40 41 typedef enum { 42 MIXER_CHANNEL_PSG = 0, 43 MIXER_CHANNEL_SCC, 44 MIXER_CHANNEL_MSXMUSIC, 45 MIXER_CHANNEL_MSXAUDIO, 46 MIXER_CHANNEL_MOONSOUND, 47 MIXER_CHANNEL_YAMAHA_SFG, 48 MIXER_CHANNEL_KEYBOARD, 49 MIXER_CHANNEL_PCM, 50 MIXER_CHANNEL_IO, 51 MIXER_CHANNEL_MIDI, 52 MIXER_CHANNEL_TYPE_COUNT 53 } MixerAudioType; 54 55 typedef enum { 56 MIXER_CHANNEL_LEFT = 0, 57 MIXER_CHANNEL_RIGHT 58 } MixerChannelPan; 59 60 #define MAX_CHANNELS 16 61 62 typedef Int32* (*MixerUpdateCallback)(void*, UInt32); 63 typedef void (*MixerSetSampleRateCallback)(void*, UInt32); 64 typedef Int32 (*MixerWriteCallback)(void*, Int16*, UInt32); 65 66 /* Constructor and destructor */ 67 Mixer* mixerCreate(); 68 void mixerDestroy(Mixer* mixer); 69 70 Mixer* mixerGetGlobalMixer(); 71 72 Int32 mixerGetMasterVolume(Mixer* mixer, int leftRight); 73 void mixerSetMasterVolume(Mixer* mixer, Int32 volume); 74 void mixerEnableMaster(Mixer* mixer, Int32 enable); 75 void mixerSetStereo(Mixer* mixer, Int32 stereo); 76 UInt32 mixerGetSampleRate(Mixer* mixer); 77 void mixerSetSampleRate(Mixer* mixer, UInt32 rate); 78 79 Int32 mixerGetChannelTypeVolume(Mixer* mixer, Int32 channelType, int leftRight); 80 void mixerSetChannelTypeVolume(Mixer* mixer, Int32 channelType, Int32 volume); 81 void mixerSetChannelTypePan(Mixer* mixer, Int32 channelType, Int32 pan); 82 void mixerEnableChannelType(Mixer* mixer, Int32 channelType, Int32 enable); 83 Int32 mixerIsChannelTypeActive(Mixer* mixer, Int32 channelType, Int32 reset); 84 85 /* Write callback registration for audio drivers */ 86 void mixerSetWriteCallback(Mixer* mixer, MixerWriteCallback callback, void*, int); 87 88 /* File logging methods */ 89 void mixerStartLog(Mixer* mixer, char* fileName); 90 int mixerIsLogging(Mixer* mixer); 91 void mixerStopLog(Mixer* mixer); 92 93 /* Internal interface methods */ 94 void mixerReset(Mixer* mixer); 95 void mixerSync(Mixer* mixer); 96 97 Int32 mixerRegisterChannel(Mixer* mixer, Int32 audioType, Int32 stereo, 98 MixerUpdateCallback callback, MixerSetSampleRateCallback rateCallback, 99 void*param); 100 void mixerSetEnable(Mixer* mixer, int enable); 101 void mixerUnregisterChannel(Mixer* mixer, Int32 handle); 102 103 void mixerSetBoardFrequency(int CPUFrequency); 104 void mixerSetBoardFrequencyFixed(int CPUFrequency); 105 106 #endif 107 108