some work on ASIO
This commit is contained in:
parent
7cd1c095f9
commit
c1f366cdf5
2 changed files with 58 additions and 84 deletions
|
@ -637,47 +637,20 @@ CSound::~CSound()
|
||||||
// ASIO callbacks -------------------------------------------------------------
|
// ASIO callbacks -------------------------------------------------------------
|
||||||
ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime *timeInfo, long index, ASIOBool processNow )
|
ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime *timeInfo, long index, ASIOBool processNow )
|
||||||
{
|
{
|
||||||
|
bufferSwitch ( index, processNow );
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSound::bufferSwitch( long index, ASIOBool processNow )
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
static long processedSamples = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static long processedSamples = 0;
|
|
||||||
|
|
||||||
// store the timeInfo for later use
|
|
||||||
asioDriverInfo.tInfo = *timeInfo;
|
|
||||||
|
|
||||||
// get the time stamp of the buffer, not necessary if no
|
|
||||||
// synchronization to other media is required
|
|
||||||
if (timeInfo->timeInfo.flags & kSystemTimeValid)
|
|
||||||
asioDriverInfo.nanoSeconds = ASIO64toDouble(timeInfo->timeInfo.systemTime);
|
|
||||||
else
|
|
||||||
asioDriverInfo.nanoSeconds = 0;
|
|
||||||
|
|
||||||
if (timeInfo->timeInfo.flags & kSamplePositionValid)
|
|
||||||
asioDriverInfo.samples = ASIO64toDouble(timeInfo->timeInfo.samplePosition);
|
|
||||||
else
|
|
||||||
asioDriverInfo.samples = 0;
|
|
||||||
|
|
||||||
if (timeInfo->timeCode.flags & kTcValid)
|
|
||||||
asioDriverInfo.tcSamples = ASIO64toDouble(timeInfo->timeCode.timeCodeSamples);
|
|
||||||
else
|
|
||||||
asioDriverInfo.tcSamples = 0;
|
|
||||||
|
|
||||||
// get the system reference time
|
|
||||||
asioDriverInfo.sysRefTime = get_sys_reference_time();
|
|
||||||
|
|
||||||
#if WINDOWS && _DEBUG
|
|
||||||
// a few debug messages for the Windows device driver developer
|
|
||||||
// tells you the time when driver got its interrupt and the delay until the app receives
|
|
||||||
// the event notification.
|
|
||||||
static double last_samples = 0;
|
|
||||||
char tmp[128];
|
|
||||||
sprintf (tmp, "diff: %d / %d ms / %d ms / %d samples \n", asioDriverInfo.sysRefTime - (long)(asioDriverInfo.nanoSeconds / 1000000.0), asioDriverInfo.sysRefTime, (long)(asioDriverInfo.nanoSeconds / 1000000.0), (long)(asioDriverInfo.samples - last_samples));
|
|
||||||
OutputDebugString (tmp);
|
|
||||||
last_samples = asioDriverInfo.samples;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// buffer size in samples
|
// buffer size in samples
|
||||||
long buffSize = asioDriverInfo.preferredSize;
|
// long buffSize = asioDriverInfo.preferredSize;
|
||||||
|
|
||||||
// perform the processing
|
// perform the processing
|
||||||
for ( int i = 0; i < asioDriverInfo.inputBuffers + asioDriverInfo.outputBuffers; i++ )
|
for ( int i = 0; i < asioDriverInfo.inputBuffers + asioDriverInfo.outputBuffers; i++ )
|
||||||
|
@ -742,20 +715,21 @@ ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime *timeInfo, long index, ASIOBoo
|
||||||
|
|
||||||
// finally if the driver supports the ASIOOutputReady() optimization, do it here, all data are in place
|
// finally if the driver supports the ASIOOutputReady() optimization, do it here, all data are in place
|
||||||
if ( asioDriverInfo.postOutput )
|
if ( asioDriverInfo.postOutput )
|
||||||
|
{
|
||||||
ASIOOutputReady();
|
ASIOOutputReady();
|
||||||
|
}
|
||||||
|
|
||||||
if ( processedSamples >= asioDriverInfo.sampleRate * TEST_RUN_TIME ) // roughly measured
|
if ( processedSamples >= asioDriverInfo.sampleRate * TEST_RUN_TIME ) // roughly measured
|
||||||
|
{
|
||||||
asioDriverInfo.stopped = true;
|
asioDriverInfo.stopped = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
processedSamples += buffSize;
|
processedSamples += buffSize;
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSound::bufferSwitch( long index, ASIOBool processNow )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
// switch here between ASIO (Steinberg) or native Windows(TM) sound interface
|
// switch here between ASIO (Steinberg) or native Windows(TM) sound interface
|
||||||
#undef USE_ASIO_SND_INTERFACE
|
//#undef USE_ASIO_SND_INTERFACE
|
||||||
//#define USE_ASIO_SND_INTERFACE
|
#define USE_ASIO_SND_INTERFACE
|
||||||
|
|
||||||
|
|
||||||
#define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only
|
#define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only
|
||||||
|
|
Loading…
Reference in a new issue