mirror of
https://github.com/thestk/stk
synced 2026-01-17 14:41:53 +00:00
Version 4.3.1
This commit is contained in:
committed by
Stephen Sinclair
parent
27d9b79dc7
commit
d199342e86
@@ -39,10 +39,11 @@ FileRead :: FileRead()
|
||||
{
|
||||
}
|
||||
|
||||
FileRead :: FileRead( std::string fileName, bool typeRaw )
|
||||
FileRead :: FileRead( std::string fileName, bool typeRaw, unsigned int nChannels,
|
||||
StkFormat format, StkFloat rate )
|
||||
: fd_(0)
|
||||
{
|
||||
open( fileName, typeRaw );
|
||||
open( fileName, typeRaw, nChannels, format, rate );
|
||||
}
|
||||
|
||||
FileRead :: ~FileRead()
|
||||
@@ -64,7 +65,8 @@ bool FileRead :: isOpen( void )
|
||||
else return false;
|
||||
}
|
||||
|
||||
void FileRead :: open( std::string fileName, bool typeRaw )
|
||||
void FileRead :: open( std::string fileName, bool typeRaw, unsigned int nChannels,
|
||||
StkFormat format, StkFloat rate )
|
||||
{
|
||||
// If another file is open, close it.
|
||||
close();
|
||||
@@ -79,7 +81,7 @@ void FileRead :: open( std::string fileName, bool typeRaw )
|
||||
// Attempt to determine file type from header (unless RAW).
|
||||
bool result = false;
|
||||
if ( typeRaw )
|
||||
result = getRawInfo( fileName.c_str() );
|
||||
result = getRawInfo( fileName.c_str(), nChannels, format, rate );
|
||||
else {
|
||||
char header[12];
|
||||
if ( fread( &header, 4, 3, fd_ ) != 3 ) goto error;
|
||||
@@ -121,7 +123,7 @@ void FileRead :: open( std::string fileName, bool typeRaw )
|
||||
handleError( StkError::FILE_ERROR );
|
||||
}
|
||||
|
||||
bool FileRead :: getRawInfo( const char *fileName )
|
||||
bool FileRead :: getRawInfo( const char *fileName, unsigned int nChannels, StkFormat format, StkFloat rate )
|
||||
{
|
||||
// Use the system call "stat" to determine the file length.
|
||||
struct stat filestat;
|
||||
@@ -130,14 +132,22 @@ bool FileRead :: getRawInfo( const char *fileName )
|
||||
return false;
|
||||
}
|
||||
|
||||
// STK rawwave files have no header and are assumed to contain a
|
||||
// monophonic stream of 16-bit signed integers in big-endian byte
|
||||
// order at a sample rate of 22050 Hz.
|
||||
channels_ = 1;
|
||||
fileSize_ = (long) filestat.st_size / 2; // length in 2-byte samples
|
||||
// Rawwave files have no header and by default, are assumed to
|
||||
// contain a monophonic stream of 16-bit signed integers in
|
||||
// big-endian byte order at a sample rate of 22050 Hz. However,
|
||||
// different parameters can be specified if desired.
|
||||
dataOffset_ = 0;
|
||||
fileRate_ = 22050.0;
|
||||
dataType_ = STK_SINT16;
|
||||
channels_ = nChannels;
|
||||
dataType_ = format;
|
||||
fileRate_ = rate;
|
||||
int sampleBytes = 0;
|
||||
if ( format == STK_SINT8 ) sampleBytes = 1;
|
||||
else if ( format == STK_SINT16 ) sampleBytes = 2;
|
||||
else if ( format == STK_SINT32 || format == STK_FLOAT32 ) sampleBytes = 4;
|
||||
else if ( format == STK_FLOAT64 ) sampleBytes = 8;
|
||||
|
||||
fileSize_ = (long) filestat.st_size / sampleBytes / channels_; // length in frames
|
||||
|
||||
byteswap_ = false;
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
byteswap_ = true;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
### Do not edit -- Generated by 'configure --with-whatever' from Makefile.in
|
||||
### libstk Makefile - for various flavors of unix
|
||||
|
||||
LIBRARY = libstk.a
|
||||
@@ -38,11 +39,11 @@ CC = @CXX@
|
||||
DEFS = @byte_order@
|
||||
DEFS += @debug@
|
||||
CFLAGS = @cflags@
|
||||
CFLAGS += @warn@ $(INCLUDE)
|
||||
CFLAGS += @warn@ $(INCLUDE) -Iinclude
|
||||
|
||||
REALTIME = @realtime@
|
||||
ifeq ($(REALTIME),yes)
|
||||
OBJECTS += RtMidi.o RtAudio.o RtWvOut.o RtWvIn.o InetWvOut.o InetWvIn.o Thread.o Mutex.o Socket.o TcpClient.o TcpServer.o UdpSocket.o
|
||||
OBJECTS += RtMidi.o RtAudio.o RtWvOut.o RtWvIn.o InetWvOut.o InetWvIn.o Thread.o Mutex.o Socket.o TcpClient.o TcpServer.o UdpSocket.o @objects@
|
||||
DEFS += @audio_apis@
|
||||
endif
|
||||
|
||||
@@ -55,6 +56,9 @@ DEFS += -DRAWWAVE_PATH=\"$(RAWWAVES)\"
|
||||
%.o : %.cpp
|
||||
$(CC) $(CFLAGS) $(DEFS) -c $(<) -o $(OBJECT_PATH)/$@
|
||||
|
||||
%.o : ../src/include/%.cpp
|
||||
$(CC) $(CFLAGS) $(DEFS) -c $(<) -o $(OBJECT_PATH)/$@
|
||||
|
||||
all : $(LIBRARY)
|
||||
|
||||
$(LIBRARY) : $(OBJECTS)
|
||||
|
||||
122
src/RtAudio.cpp
122
src/RtAudio.cpp
@@ -38,7 +38,7 @@
|
||||
*/
|
||||
/************************************************************************/
|
||||
|
||||
// RtAudio: Version 4.0
|
||||
// RtAudio: Version 4.0.3
|
||||
|
||||
#include "RtAudio.h"
|
||||
#include <iostream>
|
||||
@@ -539,7 +539,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
|
||||
error( RtError::WARNING );
|
||||
return info;
|
||||
}
|
||||
info.name.append( (const char *)name, strlen(name) + 1 );
|
||||
info.name.append( (const char *)name, strlen(name) );
|
||||
info.name.append( ": " );
|
||||
|
||||
dataSize = 256;
|
||||
@@ -552,7 +552,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
|
||||
error( RtError::WARNING );
|
||||
return info;
|
||||
}
|
||||
info.name.append( (const char *)name, strlen(name) + 1 );
|
||||
info.name.append( (const char *)name, strlen(name) );
|
||||
|
||||
// Get the output stream "configuration".
|
||||
AudioBufferList *bufferList = nil;
|
||||
@@ -2291,10 +2291,10 @@ bool RtApiJack :: callbackEvent( unsigned long nframes )
|
||||
// on information found in
|
||||
// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html.
|
||||
|
||||
#include "asio/asiosys.h"
|
||||
#include "asio/asio.h"
|
||||
#include "asio/iasiothiscallresolver.h"
|
||||
#include "asio/asiodrivers.h"
|
||||
#include "asiosys.h"
|
||||
#include "asio.h"
|
||||
#include "iasiothiscallresolver.h"
|
||||
#include "asiodrivers.h"
|
||||
#include <cmath>
|
||||
|
||||
AsioDrivers drivers;
|
||||
@@ -2366,11 +2366,14 @@ RtAudio::DeviceInfo RtApiAsio :: getDeviceInfo( unsigned int device )
|
||||
error( RtError::INVALID_USE );
|
||||
}
|
||||
|
||||
// Don't probe if a stream is already open.
|
||||
// If a stream is already open, we cannot probe other devices. Thus, use the saved results.
|
||||
if ( stream_.state != STREAM_CLOSED ) {
|
||||
errorText_ = "RtApiAsio::getDeviceInfo: unable to probe driver while a stream is open.";
|
||||
error( RtError::WARNING );
|
||||
return info;
|
||||
if ( device >= devices_.size() ) {
|
||||
errorText_ = "RtApiAsio::getDeviceInfo: device ID was not present before stream was opened.";
|
||||
error( RtError::WARNING );
|
||||
return info;
|
||||
}
|
||||
return devices_[ device ];
|
||||
}
|
||||
|
||||
char driverName[32];
|
||||
@@ -2463,6 +2466,16 @@ void bufferSwitch( long index, ASIOBool processNow )
|
||||
object->callbackEvent( index );
|
||||
}
|
||||
|
||||
void RtApiAsio :: saveDeviceInfo( void )
|
||||
{
|
||||
devices_.clear();
|
||||
|
||||
unsigned int nDevices = getDeviceCount();
|
||||
devices_.resize( nDevices );
|
||||
for ( unsigned int i=0; i<nDevices; i++ )
|
||||
devices_[i] = getDeviceInfo( i );
|
||||
}
|
||||
|
||||
bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
|
||||
unsigned int firstChannel, unsigned int sampleRate,
|
||||
RtAudioFormat format, unsigned int *bufferSize,
|
||||
@@ -2482,6 +2495,12 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// The getDeviceInfo() function will not work when a stream is open
|
||||
// because ASIO does not allow multiple devices to run at the same
|
||||
// time. Thus, we'll probe the system before opening a stream and
|
||||
// save the results for use by getDeviceInfo().
|
||||
this->saveDeviceInfo();
|
||||
|
||||
// Only load the driver once for duplex stream.
|
||||
if ( mode != INPUT || stream_.mode != OUTPUT ) {
|
||||
if ( !drivers.loadDriver( driverName ) ) {
|
||||
@@ -2528,15 +2547,27 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// Set the sample rate.
|
||||
result = ASIOSetSampleRate( (ASIOSampleRate) sampleRate );
|
||||
// Get the current sample rate
|
||||
ASIOSampleRate currentRate;
|
||||
result = ASIOGetSampleRate( ¤tRate );
|
||||
if ( result != ASE_OK ) {
|
||||
drivers.removeCurrentDriver();
|
||||
errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error setting sample rate (" << sampleRate << ").";
|
||||
errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error getting sample rate.";
|
||||
errorText_ = errorStream_.str();
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// Set the sample rate only if necessary
|
||||
if ( currentRate != sampleRate ) {
|
||||
result = ASIOSetSampleRate( (ASIOSampleRate) sampleRate );
|
||||
if ( result != ASE_OK ) {
|
||||
drivers.removeCurrentDriver();
|
||||
errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error setting sample rate (" << sampleRate << ").";
|
||||
errorText_ = errorStream_.str();
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the driver data type.
|
||||
ASIOChannelInfo channelInfo;
|
||||
channelInfo.channel = 0;
|
||||
@@ -2696,7 +2727,8 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
|
||||
stream_.doConvertBuffer[mode] = true;
|
||||
|
||||
// Allocate necessary internal buffers
|
||||
unsigned long bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );
|
||||
unsigned long bufferBytes;
|
||||
bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );
|
||||
stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );
|
||||
if ( stream_.userBuffer[mode] == NULL ) {
|
||||
errorText_ = "RtApiAsio::probeDeviceOpen: error allocating user buffer memory.";
|
||||
@@ -2958,8 +2990,8 @@ bool RtApiAsio :: callbackEvent( long bufferIndex )
|
||||
handle->internalDrain = true;
|
||||
}
|
||||
|
||||
unsigned int bufferBytes, i, j;
|
||||
unsigned int nChannels = stream_.nDeviceChannels[0] + stream_.nDeviceChannels[1];
|
||||
unsigned int nChannels, bufferBytes, i, j;
|
||||
nChannels = stream_.nDeviceChannels[0] + stream_.nDeviceChannels[1];
|
||||
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
|
||||
|
||||
bufferBytes = stream_.bufferSize * formatBytes( stream_.deviceFormat[0] );
|
||||
@@ -3187,6 +3219,14 @@ static const char* getAsioErrorString( ASIOError result )
|
||||
#include <dsound.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
// missing from latest mingw winapi
|
||||
#define WAVE_FORMAT_96M08 0x00010000 /* 96 kHz, Mono, 8-bit */
|
||||
#define WAVE_FORMAT_96S08 0x00020000 /* 96 kHz, Stereo, 8-bit */
|
||||
#define WAVE_FORMAT_96M16 0x00040000 /* 96 kHz, Mono, 16-bit */
|
||||
#define WAVE_FORMAT_96S16 0x00080000 /* 96 kHz, Stereo, 16-bit */
|
||||
#endif
|
||||
|
||||
#define MINIMUM_DEVICE_BUFFER_SIZE 32768
|
||||
|
||||
#ifdef _MSC_VER // if Microsoft Visual C++
|
||||
@@ -3223,7 +3263,7 @@ struct DsHandle {
|
||||
HANDLE condition;
|
||||
|
||||
DsHandle()
|
||||
:drainCounter(0), internalDrain(false) { id[0] = 0, id[1] = 0; xrun[0] = false; xrun[1] = false; bufferPointer[0] = 0; bufferPointer[1] = 0; }
|
||||
:drainCounter(0), internalDrain(false) { id[0] = 0; id[1] = 0; buffer[0] = 0; buffer[1] = 0; xrun[0] = false; xrun[1] = false; bufferPointer[0] = 0; bufferPointer[1] = 0; }
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -3247,7 +3287,7 @@ RtApiDs::RtDsStatistics RtApiDs::getDsStatistics()
|
||||
|
||||
// Declarations for utility functions, callbacks, and structures
|
||||
// specific to the DirectSound implementation.
|
||||
static bool CALLBACK deviceCountCallback( LPGUID lpguid,
|
||||
static BOOL CALLBACK deviceQueryCallback( LPGUID lpguid,
|
||||
LPCTSTR description,
|
||||
LPCTSTR module,
|
||||
LPVOID lpContext );
|
||||
@@ -3288,7 +3328,7 @@ unsigned int RtApiDs :: getDefaultInputDevice( void )
|
||||
{
|
||||
// Count output devices.
|
||||
EnumInfo info;
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::getDefaultOutputDevice: error (" << getErrorString( result ) << ") counting output devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3299,7 +3339,7 @@ unsigned int RtApiDs :: getDefaultInputDevice( void )
|
||||
// Now enumerate input devices until we find the id = NULL.
|
||||
info.isInput = true;
|
||||
info.getDefault = true;
|
||||
result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
|
||||
result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::getDefaultInputDevice: error (" << getErrorString( result ) << ") enumerating input devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3316,7 +3356,7 @@ unsigned int RtApiDs :: getDefaultOutputDevice( void )
|
||||
// Enumerate output devices until we find the id = NULL.
|
||||
EnumInfo info;
|
||||
info.getDefault = true;
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::getDefaultOutputDevice: error (" << getErrorString( result ) << ") enumerating output devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3332,7 +3372,7 @@ unsigned int RtApiDs :: getDeviceCount( void )
|
||||
{
|
||||
// Count DirectSound devices.
|
||||
EnumInfo info;
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::getDeviceCount: error (" << getErrorString( result ) << ") enumerating output devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3341,7 +3381,7 @@ unsigned int RtApiDs :: getDeviceCount( void )
|
||||
|
||||
// Count DirectSoundCapture devices.
|
||||
info.isInput = true;
|
||||
result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
|
||||
result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::getDeviceCount: error (" << getErrorString( result ) << ") enumerating input devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3366,7 +3406,7 @@ RtAudio::DeviceInfo RtApiDs :: getDeviceInfo( unsigned int device )
|
||||
EnumInfo dsinfo;
|
||||
dsinfo.findIndex = true;
|
||||
dsinfo.index = device;
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") enumerating output devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3424,7 +3464,7 @@ RtAudio::DeviceInfo RtApiDs :: getDeviceInfo( unsigned int device )
|
||||
probeInput:
|
||||
|
||||
dsinfo.isInput = true;
|
||||
result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
|
||||
result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") enumerating input devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3534,7 +3574,7 @@ bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned
|
||||
EnumInfo dsinfo;
|
||||
dsinfo.findIndex = true;
|
||||
dsinfo.index = device;
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
|
||||
HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::probeDeviceOpen: error (" << getErrorString( result ) << ") enumerating output devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3550,7 +3590,7 @@ bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned
|
||||
}
|
||||
else { // mode == INPUT
|
||||
dsinfo.isInput = true;
|
||||
HRESULT result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
|
||||
HRESULT result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
|
||||
if ( FAILED( result ) ) {
|
||||
errorStream_ << "RtApiDs::probeDeviceOpen: error (" << getErrorString( result ) << ") enumerating input devices!";
|
||||
errorText_ = errorStream_.str();
|
||||
@@ -3858,6 +3898,7 @@ bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned
|
||||
}
|
||||
|
||||
// Set various stream parameters
|
||||
DsHandle *handle = 0;
|
||||
stream_.nDeviceChannels[mode] = channels + firstChannel;
|
||||
stream_.nUserChannels[mode] = channels;
|
||||
stream_.bufferSize = *bufferSize;
|
||||
@@ -3907,7 +3948,6 @@ bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned
|
||||
}
|
||||
|
||||
// Allocate our DsHandle structures for the stream.
|
||||
DsHandle *handle;
|
||||
if ( stream_.apiHandle == 0 ) {
|
||||
try {
|
||||
handle = new DsHandle;
|
||||
@@ -4078,7 +4118,7 @@ void RtApiDs :: startStream()
|
||||
duplexPrerollBytes = (int) ( 0.5 * stream_.sampleRate * formatBytes( stream_.deviceFormat[1] ) * stream_.nDeviceChannels[1] );
|
||||
}
|
||||
|
||||
HRESULT result;
|
||||
HRESULT result = 0;
|
||||
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
|
||||
//statistics.outputFrameSize = formatBytes( stream_.deviceFormat[0] ) * stream_.nDeviceChannels[0];
|
||||
|
||||
@@ -4124,7 +4164,7 @@ void RtApiDs :: stopStream()
|
||||
|
||||
MUTEX_LOCK( &stream_.mutex );
|
||||
|
||||
HRESULT result;
|
||||
HRESULT result = 0;
|
||||
LPVOID audioPtr;
|
||||
DWORD dataLen;
|
||||
DsHandle *handle = (DsHandle *) stream_.apiHandle;
|
||||
@@ -4665,7 +4705,7 @@ std::string convertTChar( LPCTSTR name )
|
||||
return s;
|
||||
}
|
||||
|
||||
static bool CALLBACK deviceCountCallback( LPGUID lpguid,
|
||||
static BOOL CALLBACK deviceQueryCallback( LPGUID lpguid,
|
||||
LPCTSTR description,
|
||||
LPCTSTR module,
|
||||
LPVOID lpContext )
|
||||
@@ -4678,7 +4718,7 @@ static bool CALLBACK deviceCountCallback( LPGUID lpguid,
|
||||
LPDIRECTSOUNDCAPTURE object;
|
||||
|
||||
hr = DirectSoundCaptureCreate( lpguid, &object, NULL );
|
||||
if ( hr != DS_OK ) return true;
|
||||
if ( hr != DS_OK ) return TRUE;
|
||||
|
||||
caps.dwSize = sizeof(caps);
|
||||
hr = object->GetCaps( &caps );
|
||||
@@ -4692,7 +4732,7 @@ static bool CALLBACK deviceCountCallback( LPGUID lpguid,
|
||||
DSCAPS caps;
|
||||
LPDIRECTSOUND object;
|
||||
hr = DirectSoundCreate( lpguid, &object, NULL );
|
||||
if ( hr != DS_OK ) return true;
|
||||
if ( hr != DS_OK ) return TRUE;
|
||||
|
||||
caps.dwSize = sizeof(caps);
|
||||
hr = object->GetCaps( &caps );
|
||||
@@ -4703,20 +4743,20 @@ static bool CALLBACK deviceCountCallback( LPGUID lpguid,
|
||||
object->Release();
|
||||
}
|
||||
|
||||
if ( info->getDefault && lpguid == NULL ) return false;
|
||||
if ( info->getDefault && lpguid == NULL ) return FALSE;
|
||||
|
||||
if ( info->findIndex && info->counter > info->index ) {
|
||||
info->id = lpguid;
|
||||
info->name = convertTChar( description );
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char* getErrorString( int code )
|
||||
{
|
||||
switch (code) {
|
||||
switch ( code ) {
|
||||
|
||||
case DSERR_ALLOCATED:
|
||||
return "Already allocated";
|
||||
@@ -5906,7 +5946,9 @@ extern "C" void *alsaCallbackHandler( void *ptr )
|
||||
#ifdef SCHED_RR
|
||||
// Set a higher scheduler priority (P.J. Leonard)
|
||||
struct sched_param param;
|
||||
param.sched_priority = 39; // Is this the best number?
|
||||
int min = sched_get_priority_min( SCHED_RR );
|
||||
int max = sched_get_priority_max( SCHED_RR );
|
||||
param.sched_priority = min + ( max - min ) / 2; // Is this the best number?
|
||||
sched_setscheduler( 0, SCHED_RR, ¶m );
|
||||
#endif
|
||||
|
||||
@@ -5928,7 +5970,7 @@ extern "C" void *alsaCallbackHandler( void *ptr )
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "oss/soundcard.h"
|
||||
#include "soundcard.h"
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
RtMidi WWW site: http://music.mcgill.ca/~gary/rtmidi/
|
||||
|
||||
RtMidi: realtime MIDI i/o C++ classes
|
||||
Copyright (c) 2003-2005 Gary P. Scavone
|
||||
Copyright (c) 2003-2007 Gary P. Scavone
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
@@ -35,7 +35,7 @@
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
// RtMidi: Version 1.0.5, in development
|
||||
// RtMidi: Version 1.0.7
|
||||
|
||||
#include "RtMidi.h"
|
||||
#include <sstream>
|
||||
@@ -768,12 +768,9 @@ extern "C" void *alsaMidiHandler( void *ptr )
|
||||
else
|
||||
message.bytes.insert( message.bytes.end(), buffer, &buffer[nBytes] );
|
||||
|
||||
if ( ev->type == SND_SEQ_EVENT_SYSEX && message.bytes.back() == 0xF7 )
|
||||
continueSysex = false;
|
||||
else {
|
||||
continueSysex = true;
|
||||
continueSysex = ( ev->type == SND_SEQ_EVENT_SYSEX && message.bytes.back() != 0xF7 );
|
||||
if ( continueSysex )
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculate the time stamp:
|
||||
message.timeStamp = 0.0;
|
||||
@@ -1926,7 +1923,7 @@ std::string RtMidiIn :: getPortName( unsigned int portNumber )
|
||||
}
|
||||
|
||||
MIDIINCAPS deviceCaps;
|
||||
MMRESULT result = midiInGetDevCaps( portNumber, &deviceCaps, sizeof(MIDIINCAPS));
|
||||
midiInGetDevCaps( portNumber, &deviceCaps, sizeof(MIDIINCAPS));
|
||||
|
||||
// For some reason, we need to copy character by character with
|
||||
// UNICODE (thanks to Eduardo Coutinho!).
|
||||
@@ -1960,7 +1957,7 @@ std::string RtMidiOut :: getPortName( unsigned int portNumber )
|
||||
}
|
||||
|
||||
MIDIOUTCAPS deviceCaps;
|
||||
MMRESULT result = midiOutGetDevCaps( portNumber, &deviceCaps, sizeof(MIDIOUTCAPS));
|
||||
midiOutGetDevCaps( portNumber, &deviceCaps, sizeof(MIDIOUTCAPS));
|
||||
|
||||
// For some reason, we need to copy character by character with
|
||||
// UNICODE (thanks to Eduardo Coutinho!).
|
||||
|
||||
@@ -104,7 +104,7 @@ RtWvOut :: RtWvOut( unsigned int nChannels, StkFloat sampleRate, int device, int
|
||||
}
|
||||
|
||||
data_.resize( size * nBuffers, nChannels );
|
||||
unsigned int offset = (unsigned int ) (data_.size() / 2.0);
|
||||
unsigned int offset = (unsigned int ) (data_.frames() / 2.0);
|
||||
writeIndex_ = offset; // start writing half-way into buffer
|
||||
framesFilled_ = offset;
|
||||
}
|
||||
|
||||
16
src/Stk.cpp
16
src/Stk.cpp
@@ -8,7 +8,21 @@
|
||||
provides error handling and byte-swapping
|
||||
functions.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
|
||||
The Synthesis ToolKit in C++ (STK) is a set of open source audio
|
||||
signal processing and algorithmic synthesis classes written in the
|
||||
C++ programming language. STK was designed to facilitate rapid
|
||||
development of music synthesis and audio processing software, with
|
||||
an emphasis on cross-platform functionality, realtime control,
|
||||
ease of use, and educational example code. STK currently runs
|
||||
with realtime support (audio and MIDI) on Linux, Macintosh OS X,
|
||||
and Windows computer platforms. Generic, non-realtime support has
|
||||
been tested under NeXTStep, Sun, and other platforms and should
|
||||
work with any standard C++ compiler.
|
||||
|
||||
STK WWW site: http://ccrma.stanford.edu/software/stk/
|
||||
|
||||
The Synthesis ToolKit in C++ (STK)
|
||||
Copyright (c) 1995-2007 Perry R. Cook and Gary P. Scavone
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
|
||||
2369
src/include/dsound.h
Normal file
2369
src/include/dsound.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user