1 // **************************************************************************** 2 // 3 // CDarla24DspCommObject.cpp 4 // 5 // Implementation file for Darla24 DSP interface class. 6 // 7 // Copyright Echo Digital Audio Corporation (c) 1998 - 2002 8 // All rights reserved 9 // www.echoaudio.com 10 // 11 // Permission is hereby granted, free of charge, to any person obtaining a 12 // copy of this software and associated documentation files (the 13 // "Software"), to deal with the Software without restriction, including 14 // without limitation the rights to use, copy, modify, merge, publish, 15 // distribute, sublicense, and/or sell copies of the Software, and to 16 // permit persons to whom the Software is furnished to do so, subject to 17 // the following conditions: 18 // 19 // - Redistributions of source code must retain the above copyright 20 // notice, this list of conditions and the following disclaimers. 21 // 22 // - Redistributions in binary form must reproduce the above copyright 23 // notice, this list of conditions and the following disclaimers in the 24 // documentation and/or other materials provided with the distribution. 25 // 26 // - Neither the name of Echo Digital Audio, nor the names of its 27 // contributors may be used to endorse or promote products derived from 28 // this Software without specific prior written permission. 29 // 30 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 31 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 32 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 33 // IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR 34 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 35 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 36 // SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. 37 // 38 // **************************************************************************** 39 40 #include "CEchoGals.h" 41 #include "CDarla24DspCommObject.h" 42 43 #include "Darla24DSP.c" 44 45 46 /**************************************************************************** 47 48 Magic constants for the Darla24 hardware 49 50 ****************************************************************************/ 51 52 #define GD24_96000 0x0 53 #define GD24_48000 0x1 54 #define GD24_44100 0x2 55 #define GD24_32000 0x3 56 #define GD24_22050 0x4 57 #define GD24_16000 0x5 58 #define GD24_11025 0x6 59 #define GD24_8000 0x7 60 #define GD24_88200 0x8 61 #define GD24_EXT_SYNC 0x9 62 63 64 65 66 /**************************************************************************** 67 68 Construction and destruction 69 70 ****************************************************************************/ 71 72 //=========================================================================== 73 // 74 // Constructor 75 // 76 //=========================================================================== 77 78 CDarla24DspCommObject::CDarla24DspCommObject 79 ( 80 PDWORD pdwRegBase, // Virtual ptr to DSP registers 81 PCOsSupport pOsSupport 82 ) : CGdDspCommObject( pdwRegBase, pOsSupport ) 83 { 84 strcpy( m_szCardName, "Darla24" ); 85 m_pdwDspRegBase = pdwRegBase; // Virtual addr DSP's register base 86 87 m_wNumPipesOut = 8; 88 m_wNumPipesIn = 2; 89 m_wNumBussesOut = 8; 90 m_wNumBussesIn = 2; 91 m_wFirstDigitalBusOut = 8; 92 m_wFirstDigitalBusIn = 2; 93 94 m_fHasVmixer = FALSE; 95 96 m_wNumMidiOut = 0; // # MIDI out channels 97 m_wNumMidiIn = 0; // # MIDI in channels 98 m_pDspCommPage->dwSampleRate = SWAP( (DWORD) 44100 ); 99 // Need this in case we start with ESYNC 100 101 m_pwDspCodeToLoad = pwDarla24DSP; 102 103 // 104 // Since this card has no ASIC, mark it as loaded so everything works OK 105 // 106 m_bASICLoaded = TRUE; 107 108 } // CDarla24DspCommObject::CDarla24DspCommObject( DWORD dwPhysRegBase ) 109 110 111 //=========================================================================== 112 // 113 // Destructor 114 // 115 //=========================================================================== 116 117 CDarla24DspCommObject::~CDarla24DspCommObject() 118 { 119 } // CDarla24DspCommObject::~CDarla24DspCommObject() 120 121 122 123 124 /**************************************************************************** 125 126 Hardware config 127 128 ****************************************************************************/ 129 130 //=========================================================================== 131 // 132 // SetSampleRate 133 // 134 // Set the audio sample rate for Darla24; this is fairly simple. You 135 // just pick the right magic number. 136 // 137 //=========================================================================== 138 139 DWORD CDarla24DspCommObject::SetSampleRate( DWORD dwNewSampleRate ) 140 { 141 BYTE bClock; 142 143 // 144 // Pick the magic number 145 // 146 switch ( dwNewSampleRate ) 147 { 148 case 96000 : 149 bClock = GD24_96000; 150 break; 151 case 88200 : 152 bClock = GD24_88200; 153 break; 154 case 48000 : 155 bClock = GD24_48000; 156 break; 157 case 44100 : 158 bClock = GD24_44100; 159 break; 160 case 32000 : 161 bClock = GD24_32000; 162 break; 163 case 22050 : 164 bClock = GD24_22050; 165 break; 166 case 16000 : 167 bClock = GD24_16000; 168 break; 169 case 11025 : 170 bClock = GD24_11025; 171 break; 172 case 8000 : 173 bClock = GD24_8000; 174 break; 175 default : 176 ECHO_DEBUGPRINTF( ("CDarla24DspCommObject::SetSampleRate: Error, " 177 "invalid sample rate 0x%lx\n", dwNewSampleRate) ); 178 return 0xffffffff; 179 } 180 181 if ( !WaitForHandshake() ) 182 return 0xffffffff; 183 184 // 185 // Override the sample rate if this card is set to Echo sync. 186 // m_pDspCommPage->wInputClock is just being used as a parameter here; 187 // the DSP ignores it. 188 // 189 if ( ECHO_CLOCK_ESYNC == GetInputClock() ) 190 bClock = GD24_EXT_SYNC; 191 192 m_pDspCommPage->dwSampleRate = SWAP( dwNewSampleRate ); 193 194 // 195 // Write the audio state to the comm page 196 // 197 m_pDspCommPage->byGDClockState = bClock; 198 199 // Send command to DSP 200 ClearHandshake(); 201 SendVector( DSP_VC_SET_GD_AUDIO_STATE ); 202 203 ECHO_DEBUGPRINTF( ("CDarla24DspCommObject::SetSampleRate: 0x%lx " 204 "clocks %s\n", dwNewSampleRate) ); 205 206 return GetSampleRate(); 207 208 } // DWORD CDarla24DspCommObject::SetSampleRate( DWORD dwNewSampleRate ) 209 210 211 //=========================================================================== 212 // 213 // Set input clock 214 // 215 // Darla24 supports internal and Esync clock. 216 // 217 //=========================================================================== 218 219 ECHOSTATUS CDarla24DspCommObject::SetInputClock(WORD wClock) 220 { 221 if ( (ECHO_CLOCK_INTERNAL != wClock) && 222 (ECHO_CLOCK_ESYNC != wClock)) 223 return ECHOSTATUS_CLOCK_NOT_SUPPORTED; 224 225 m_wInputClock = wClock; 226 227 return SetSampleRate( GetSampleRate() ); 228 229 } // SetInputClock 230 231 232 // **** Darla24DspCommObject.cpp **** 233