2024-12-01 19:35:24 +00:00
|
|
|
//| Copyright: (C) 2020-2024 Kevin Larke <contact AT larke DOT org>
|
|
|
|
//| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
|
2023-02-02 23:22:05 +00:00
|
|
|
#ifndef cwAudioDeviceFile_H
|
|
|
|
#define cwAudioDeviceFile_H
|
|
|
|
|
|
|
|
|
|
|
|
namespace cw
|
|
|
|
{
|
|
|
|
namespace audio
|
|
|
|
{
|
|
|
|
namespace device
|
|
|
|
{
|
|
|
|
namespace file
|
|
|
|
{
|
|
|
|
typedef handle<struct dev_mgr_str> handle_t;
|
2023-02-26 18:11:07 +00:00
|
|
|
|
|
|
|
rc_t create( handle_t& hRef, struct driver_str*& drvRef);
|
2023-02-02 23:22:05 +00:00
|
|
|
rc_t destroy( handle_t& hRef );
|
2023-02-15 01:52:32 +00:00
|
|
|
rc_t start( handle_t h );
|
|
|
|
rc_t stop( handle_t h );
|
2023-02-02 23:22:05 +00:00
|
|
|
|
|
|
|
unsigned deviceCount( struct driver_str* drv);
|
|
|
|
const char* deviceLabel( struct driver_str* drv, unsigned devIdx );
|
|
|
|
unsigned deviceChannelCount( struct driver_str* drv, unsigned devIdx, bool inputFl );
|
|
|
|
double deviceSampleRate( struct driver_str* drv, unsigned devIdx );
|
|
|
|
unsigned deviceFramesPerCycle( struct driver_str* drv, unsigned devIdx, bool inputFl );
|
2023-02-15 01:52:32 +00:00
|
|
|
rc_t deviceSetup( struct driver_str* drv, unsigned devIdx, double sr, unsigned frmPerCycle, cbFunc_t cbFunc, void* cbArg, unsigned cbDevIdx );
|
2023-02-02 23:22:05 +00:00
|
|
|
rc_t deviceStart( struct driver_str* drv, unsigned devIdx );
|
|
|
|
rc_t deviceStop( struct driver_str* drv, unsigned devIdx );
|
|
|
|
bool deviceIsStarted( struct driver_str* drv, unsigned devIdx );
|
2023-02-19 19:16:37 +00:00
|
|
|
rc_t deviceExecute( struct driver_str* drv, unsigned devIdx );
|
|
|
|
rc_t deviceEnable( struct driver_str* drv, unsigned devIdx, bool inputFl, bool enableFl );
|
|
|
|
rc_t deviceSeek( struct driver_str* drv, unsigned devIdx, bool inputFl, unsigned frameOffset );
|
2023-02-02 23:22:05 +00:00
|
|
|
void deviceRealTimeReport( struct driver_str* drv, unsigned devIdx );
|
|
|
|
|
|
|
|
enum {
|
2023-02-26 18:11:07 +00:00
|
|
|
kRewindOnStartFl = 0x01, // rewind the in/out file deviceStart()
|
|
|
|
kCacheFl = 0x02, // if set then cache in/out audio in memory, otherwise access disk file
|
|
|
|
kUseInternalClockFl = 0x04, // if set then callback from internal thread, else callback from deviceExecute()
|
|
|
|
|
2023-02-02 23:22:05 +00:00
|
|
|
};
|
2023-02-15 01:52:32 +00:00
|
|
|
|
|
|
|
// A device may have an input, an output or both.
|
|
|
|
// A device with both an input and output can be created by assigning both to the same label
|
|
|
|
rc_t createInDevice( handle_t& h, const char* label, const char* audioInFName, unsigned flags );
|
2023-02-18 18:50:00 +00:00
|
|
|
|
|
|
|
// Set bitsPerSample to 0 to write in single prec. float.
|
2023-02-26 18:11:07 +00:00
|
|
|
rc_t createOutDevice( handle_t& h, const char* label, const char* audioOutFName, unsigned flags, unsigned chCnt, unsigned bitsPerSample, unsigned cacheBlockSec=10 );
|
2023-02-02 23:22:05 +00:00
|
|
|
|
|
|
|
// Generate an audio callback on the specified device.
|
|
|
|
rc_t deviceExec( handle_t& h, unsigned devIdx );
|
|
|
|
|
|
|
|
rc_t report(handle_t h );
|
|
|
|
rc_t report();
|
2023-02-18 18:50:00 +00:00
|
|
|
rc_t test( const object_t* cfg );
|
2023-02-02 23:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|