1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
////////////////////////////////////////////////////////////////////////
// This file is part of the SndObj library
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////
// SndCoreAudio.h: Interface of the SndCoreAudio class
// realtime audio IO with Mac OSX Core Audio
//
//
#ifdef MACOSX
#ifndef SndCoreAudio_H_
#define SndCoreAudio_H_
#include <CoreAudio.h>
#include "SndIO.h"
const int DEF_BSIZE = 512;
const int DEF_PERIOD = 4;
const int DEF_DEV = 0xFFFFFFFF;
class SndCoreAudio : public SndIO {
AudioDeviceID m_dev;
float** m_inbuffs;
float** m_outbuffs;
int m_sleept;
int m_dont_use_input;
int m_dont_use_output;
AudioStreamBasicDescription m_format;
unsigned int m_bufframes;
unsigned int m_buffsize;
unsigned int m_buffitems;
unsigned int m_buffnos;
unsigned int m_outcurbuff;
unsigned int m_incurbuff;
unsigned int m_iocurbuff;
unsigned int m_outcount;
unsigned int m_incount;
bool* m_inused;
bool* m_outused;
bool m_interleaved;
bool m_stopped;
bool m_called_read;
float m_norm;
int OpenDevice(bool isInput=true);
public:
SndCoreAudio(int channels=2,int bufframes=DEF_BSIZE, int buffnos=DEF_PERIOD, float norm=32767.f,
SndObj** inObjs=0, int dev=DEF_DEV,
int vecsize=DEF_VECSIZE, float sr=DEF_SR);
~SndCoreAudio();
OSStatus
ADIOProc(AudioDeviceID indev,
const AudioTimeStamp *inN, const AudioBufferList *input,
const AudioTimeStamp *inT, AudioBufferList *output,
const AudioTimeStamp *inOT, void* cdata);
void Stop(){ m_stopped = true; }
short Read();
short Write();
void SetSleepTime(int t) { m_sleept = t; }
char* ErrorMessage();
};
int ListDevices(char **d, int devs=50);
void PrintDevices();
#endif
#endif
|