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 #include "CEchoGals.h" 40 #include "CDarla24DspCommObject.h" 41 42 #include "Darla24DSP.c" 43 44 45 /**************************************************************************** 46 47 Magic constants for the Darla24 hardware 48 49 ****************************************************************************/ 50 51 #define GD24_96000 0x0 52 #define GD24_48000 0x1 53 #define GD24_44100 0x2 54 #define GD24_32000 0x3 55 #define GD24_22050 0x4 56 #define GD24_16000 0x5 57 #define GD24_11025 0x6 58 #define GD24_8000 0x7 59 #define GD24_88200 0x8 60 #define GD24_EXT_SYNC 0x9 61 62 63 64 65 /**************************************************************************** 66 67 Construction and destruction 68 69 ****************************************************************************/ 70 71 //=========================================================================== 72 // 73 // Constructor 74 // 75 //=========================================================================== 76 77 CDarla24DspCommObject::CDarla24DspCommObject 78 ( 79 PDWORD pdwRegBase, // Virtual ptr to DSP registers 80 PCOsSupport pOsSupport 81 ) : CGdDspCommObject( pdwRegBase, pOsSupport ) 82 { 83 strcpy( m_szCardName, "Darla24" ); 84 m_pdwDspRegBase = pdwRegBase; // Virtual addr DSP's register base 85 86 m_wNumPipesOut = 8; 87 m_wNumPipesIn = 2; 88 m_wNumBussesOut = 8; 89 m_wNumBussesIn = 2; 90 m_wFirstDigitalBusOut = 8; 91 m_wFirstDigitalBusIn = 2; 92 93 m_fHasVmixer = FALSE; 94 95 m_wNumMidiOut = 0; // # MIDI out channels 96 m_wNumMidiIn = 0; // # MIDI in channels 97 m_pDspCommPage->dwSampleRate = SWAP( (DWORD) 44100 ); 98 // Need this in case we start with ESYNC 99 100 m_pwDspCodeToLoad = pwDarla24DSP; 101 102 // 103 // Since this card has no ASIC, mark it as loaded so everything works OK 104 // 105 m_bASICLoaded = TRUE; 106 107 } // CDarla24DspCommObject::CDarla24DspCommObject( DWORD dwPhysRegBase ) 108 109 110 //=========================================================================== 111 // 112 // Destructor 113 // 114 //=========================================================================== 115 116 CDarla24DspCommObject::~CDarla24DspCommObject() 117 { 118 } // CDarla24DspCommObject::~CDarla24DspCommObject() 119 120 121 122 123 /**************************************************************************** 124 125 Hardware config 126 127 ****************************************************************************/ 128 129 //=========================================================================== 130 // 131 // SetSampleRate 132 // 133 // Set the audio sample rate for Darla24; this is fairly simple. You 134 // just pick the right magic number. 135 // 136 //=========================================================================== 137 138 DWORD CDarla24DspCommObject::SetSampleRate( DWORD dwNewSampleRate ) 139 { 140 BYTE bClock; 141 142 // 143 // Pick the magic number 144 // 145 switch ( dwNewSampleRate ) 146 { 147 case 96000 : 148 bClock = GD24_96000; 149 break; 150 case 88200 : 151 bClock = GD24_88200; 152 break; 153 case 48000 : 154 bClock = GD24_48000; 155 break; 156 case 44100 : 157 bClock = GD24_44100; 158 break; 159 case 32000 : 160 bClock = GD24_32000; 161 break; 162 case 22050 : 163 bClock = GD24_22050; 164 break; 165 case 16000 : 166 bClock = GD24_16000; 167 break; 168 case 11025 : 169 bClock = GD24_11025; 170 break; 171 case 8000 : 172 bClock = GD24_8000; 173 break; 174 default : 175 ECHO_DEBUGPRINTF( ("CDarla24DspCommObject::SetSampleRate: Error, " 176 "invalid sample rate 0x%lx\n", dwNewSampleRate) ); 177 return 0xffffffff; 178 } 179 180 if ( !WaitForHandshake() ) 181 return 0xffffffff; 182 183 // 184 // Override the sample rate if this card is set to Echo sync. 185 // m_pDspCommPage->wInputClock is just being used as a parameter here; 186 // the DSP ignores it. 187 // 188 if ( ECHO_CLOCK_ESYNC == GetInputClock() ) 189 bClock = GD24_EXT_SYNC; 190 191 m_pDspCommPage->dwSampleRate = SWAP( dwNewSampleRate ); 192 193 // 194 // Write the audio state to the comm page 195 // 196 m_pDspCommPage->byGDClockState = bClock; 197 198 // Send command to DSP 199 ClearHandshake(); 200 SendVector( DSP_VC_SET_GD_AUDIO_STATE ); 201 202 ECHO_DEBUGPRINTF( ("CDarla24DspCommObject::SetSampleRate: 0x%lx " 203 "clocks %d\n", dwNewSampleRate, bClock ) ); 204 205 return GetSampleRate(); 206 207 } // DWORD CDarla24DspCommObject::SetSampleRate( DWORD dwNewSampleRate ) 208 209 210 //=========================================================================== 211 // 212 // Set input clock 213 // 214 // Darla24 supports internal and Esync clock. 215 // 216 //=========================================================================== 217 218 ECHOSTATUS CDarla24DspCommObject::SetInputClock(WORD wClock) 219 { 220 if ( (ECHO_CLOCK_INTERNAL != wClock) && 221 (ECHO_CLOCK_ESYNC != wClock)) 222 return ECHOSTATUS_CLOCK_NOT_SUPPORTED; 223 224 m_wInputClock = wClock; 225 226 return SetSampleRate( GetSampleRate() ); 227 228 } // SetInputClock 229 230 231 // **** Darla24DspCommObject.cpp **** 232