1 // ****************************************************************************
3 // CDarla24DspCommObject.cpp
5 // Implementation file for Darla24 DSP interface class.
7 // ----------------------------------------------------------------------------
9 // This file is part of Echo Digital Audio's generic driver library.
10 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
11 // All rights reserved
14 // This library is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU Lesser General Public
16 // License as published by the Free Software Foundation; either
17 // version 2.1 of the License, or (at your option) any later version.
19 // This library is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 // Lesser General Public License for more details.
24 // You should have received a copy of the GNU Lesser General Public
25 // License along with this library; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // ****************************************************************************
30 #include "CEchoGals.h"
31 #include "CDarla24DspCommObject.h"
33 #include "Darla24DSP.c"
36 /****************************************************************************
38 Magic constants for the Darla24 hardware
40 ****************************************************************************/
42 #define GD24_96000 0x0
43 #define GD24_48000 0x1
44 #define GD24_44100 0x2
45 #define GD24_32000 0x3
46 #define GD24_22050 0x4
47 #define GD24_16000 0x5
48 #define GD24_11025 0x6
50 #define GD24_88200 0x8
51 #define GD24_EXT_SYNC 0x9
56 /****************************************************************************
58 Construction and destruction
60 ****************************************************************************/
62 //===========================================================================
66 //===========================================================================
68 CDarla24DspCommObject::CDarla24DspCommObject
70 PDWORD pdwRegBase
, // Virtual ptr to DSP registers
71 PCOsSupport pOsSupport
72 ) : CGdDspCommObject( pdwRegBase
, pOsSupport
)
74 strcpy( m_szCardName
, "Darla24" );
75 m_pdwDspRegBase
= pdwRegBase
; // Virtual addr DSP's register base
81 m_wFirstDigitalBusOut
= 8;
82 m_wFirstDigitalBusIn
= 2;
86 m_wNumMidiOut
= 0; // # MIDI out channels
87 m_wNumMidiIn
= 0; // # MIDI in channels
88 m_pDspCommPage
->dwSampleRate
= SWAP( (DWORD
) 44100 );
89 // Need this in case we start with ESYNC
91 m_pwDspCodeToLoad
= pwDarla24DSP
;
94 // Since this card has no ASIC, mark it as loaded so everything works OK
98 } // CDarla24DspCommObject::CDarla24DspCommObject( DWORD dwPhysRegBase )
101 //===========================================================================
105 //===========================================================================
107 CDarla24DspCommObject::~CDarla24DspCommObject()
109 } // CDarla24DspCommObject::~CDarla24DspCommObject()
114 /****************************************************************************
118 ****************************************************************************/
120 //===========================================================================
124 // Set the audio sample rate for Darla24; this is fairly simple. You
125 // just pick the right magic number.
127 //===========================================================================
129 DWORD
CDarla24DspCommObject::SetSampleRate( DWORD dwNewSampleRate
)
134 // Pick the magic number
136 switch ( dwNewSampleRate
)
166 ECHO_DEBUGPRINTF( ("CDarla24DspCommObject::SetSampleRate: Error, "
167 "invalid sample rate 0x%lx\n", dwNewSampleRate
) );
171 if ( !WaitForHandshake() )
175 // Override the sample rate if this card is set to Echo sync.
176 // m_pDspCommPage->wInputClock is just being used as a parameter here;
177 // the DSP ignores it.
179 if ( ECHO_CLOCK_ESYNC
== GetInputClock() )
180 bClock
= GD24_EXT_SYNC
;
182 m_pDspCommPage
->dwSampleRate
= SWAP( dwNewSampleRate
);
185 // Write the audio state to the comm page
187 m_pDspCommPage
->byGDClockState
= bClock
;
189 // Send command to DSP
191 SendVector( DSP_VC_SET_GD_AUDIO_STATE
);
193 ECHO_DEBUGPRINTF( ("CDarla24DspCommObject::SetSampleRate: 0x%lx "
194 "clock %d\n", dwNewSampleRate
, bClock
) );
196 return GetSampleRate();
198 } // DWORD CDarla24DspCommObject::SetSampleRate( DWORD dwNewSampleRate )
201 //===========================================================================
205 // Darla24 supports internal and Esync clock.
207 //===========================================================================
209 ECHOSTATUS
CDarla24DspCommObject::SetInputClock(WORD wClock
)
211 if ( (ECHO_CLOCK_INTERNAL
!= wClock
) &&
212 (ECHO_CLOCK_ESYNC
!= wClock
))
213 return ECHOSTATUS_CLOCK_NOT_SUPPORTED
;
215 m_wInputClock
= wClock
;
217 return SetSampleRate( GetSampleRate() );
222 // **** Darla24DspCommObject.cpp ****