/************************************************************************/
/*! \class RtAudio
\brief Realtime audio i/o C++ classes.
RtAudio provides a common API (Application Programming Interface)
for realtime audio input/output across Linux (native ALSA, Jack,
and OSS), Macintosh OS X (CoreAudio and Jack), and Windows
(DirectSound, ASIO and WASAPI) operating systems.
RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/
RtAudio: realtime audio i/o C++ classes
Copyright (c) 2001-2014 Gary P. Scavone
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Any person wishing to distribute modifications to the Software is
asked to send the modifications to the original developer so that
they can be incorporated into the canonical version. This is,
however, not a binding provision of this license.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/************************************************************************/
// RtAudio: Version 4.1.1
#include "RtAudio.h"
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <climits>
// Static variable definitions.
const unsigned int RtApi::MAX_SAMPLE_RATES = 14;
const unsigned int RtApi::SAMPLE_RATES[] = {
4000, 5512, 8000, 9600, 11025, 16000, 22050,
32000, 44100, 48000, 88200, 96000, 176400, 192000
};
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__)
#define MUTEX_INITIALIZE(A) InitializeCriticalSection(A)
#define MUTEX_DESTROY(A) DeleteCriticalSection(A)
#define MUTEX_LOCK(A) EnterCriticalSection(A)
#define MUTEX_UNLOCK(A) LeaveCriticalSection(A)
#elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)
// pthread API
#define MUTEX_INITIALIZE(A) pthread_mutex_init(A, NULL)
#define MUTEX_DESTROY(A) pthread_mutex_destroy(A)
#define MUTEX_LOCK(A) pthread_mutex_lock(A)
#define MUTEX_UNLOCK(A) pthread_mutex_unlock(A)
#else
#define MUTEX_INITIALIZE(A) abs(*A) // dummy definitions
#define MUTEX_DESTROY(A) abs(*A) // dummy definitions
#endif
// *************************************************** //
//
// RtAudio definitions.
//
// *************************************************** //
std::string RtAudio :: getVersion( void ) throw()
{
return RTAUDIO_VERSION;
}
void RtAudio :: getCompiledApi( std::vector<RtAudio::Api> &apis ) throw()
{
apis.clear();
// The order here will control the order of RtAudio's API search in
// the constructor.
#if defined(__UNIX_JACK__)
apis.push_back( UNIX_JACK );
#endif
#if defined(__LINUX_ALSA__)
apis.push_back( LINUX_ALSA );
#endif
#if defined(__LINUX_PULSE__)
apis.push_back( LINUX_PULSE );
#endif
#if defined(__LINUX_OSS__)
apis.push_back( LINUX_OSS );
#endif
#if defined(__WINDOWS_ASIO__)
apis.push_back( WINDOWS_ASIO );
#endif
#if defined(__WINDOWS_WASAPI__)
apis.push_back( WINDOWS_WASAPI );
#endif
#if defined(__WINDOWS_DS__)
apis.push_back( WINDOWS_DS );
#endif
#if defined(__MACOSX_CORE__)
apis.push_back( MACOSX_CORE );
#endif
#if defined(__RTAUDIO_DUMMY__)
apis.push_back( RTAUDIO_DUMMY );
#endif
}
void RtAudio :: openRtApi( RtAudio::Api api )
{
if ( rtapi_ )
delete rtapi_;
rtapi_ = 0;
#if defined(__UNIX_JACK__)
if ( api == UNIX_JACK )
rtapi_ = new RtApiJack();
#endif
#if defined(__LINUX_ALSA__)
if ( api == LINUX_ALSA )
rtapi_ = new RtApiAlsa();
#endif
#if defined(__LINUX_PULSE__)
if ( api == LINUX_PULSE )
rtapi_ = new RtApiPulse();
#endif
#if defined(__LINUX_OSS__)
if ( api == LINUX_OSS )
rtapi_ = new RtApiOss();
#endif
#if defined(__WINDOWS_ASIO__)
if ( api == WINDOWS_ASIO )
rtapi_ = new RtApiAsio();
#endif
#if defined(__WINDOWS_WASAPI__)
if ( api == WINDOWS_WASAPI )
rtapi_ = new RtApiWasapi();
#endif
#if defined(__WINDOWS_DS__)
if ( api == WINDOWS_DS )
rtapi_ = new RtApiDs();
#endif
#if defined(__MACOSX_CORE__)
if ( api == MACOSX_CORE )
rtapi_ = new RtApiCore();
#endif
#if defined(__RTAUDIO_DUMMY__)
if ( api == RTAUDIO_DUMMY )
rtapi_ = new RtApiDummy();
#endif
}
RtAudio :: RtAudio( RtAudio::Api api )
{
rtapi_ = 0;
if ( api != UNSPECIFIED ) {
// Attempt to open the specified API.
openRtApi( api );
if ( rtapi_ ) return;
// No compiled support for specified API value. Issue a debug
// warning and continue as if no API was specified.
std::cerr << "\nRtAudio: no compiled support for specified API argument!\n" << std::endl;
}
// Iterate through the compiled APIs and return as soon as we find
// one with at least one device or we reach the end of the list.
std::vector< RtAudio::Api > apis;
getCompiledApi( apis );
for ( unsigned int i=0; i<apis.size(); i++ ) {
openRtApi( apis[i] );
if ( rtapi_->getDeviceCount() ) break;
}
if ( rtapi_ ) return;
// It should not be possible to get here because the preprocessor
// definition __RTAUDIO_DUMMY__ is automatically defined if no
// API-specific definitions are passed to the compiler. But just in
// case something weird happens, we'll thow an error.
std::string errorText = "\nRtAudio: no compiled API support found ... critical error!!\n\n";
throw( RtAudioError( errorText, RtAudioError::UNSPECIFIED ) );
}
RtAudio :: ~RtAudio() throw()
{
if ( rtapi_ )
delete rtapi_;
}
void RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,
RtAudio::StreamParameters *inputParameters,
RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames,
RtAudioCallback callback, void *userData,
RtAudio::StreamOptions *options,
RtAudioErrorCallback errorCallback )
{
return rtapi_->openStream( outputParameters, inputParameters, format,
sampleRate, bufferFrames, callback,
userData, options, errorCallback );
}
// *************************************************** //
//
// Public RtApi definitions (see end of file for
// private or protected utility functions).
//
// *************************************************** //
RtApi :: RtApi()
{
stream_.state = STREAM_CLOSED;
stream_.mode = UNINITIALIZED;
stream_.apiHandle = 0;
stream_.userBuffer[0] = 0;
stream_.userBuffer[1] = 0;
MUTEX_INITIALIZE( &stream_.mutex );
showWarnings_ = true;
firstErrorOccurred_ = false;
}
RtApi :: ~RtApi()
{
MUTEX_DESTROY( &stream_.mutex );
}
void RtApi :: openStream( RtAudio::StreamParameters *oParams,
RtAudio::StreamParameters *iParams,
RtAudioFormat format, unsi
没有合适的资源?快使用搜索试试~ 我知道了~
rtaudio学习Demo
共117个文件
tlog:30个
h:12个
obj:11个
4星 · 超过85%的资源 需积分: 5 67 下载量 181 浏览量
2015-09-08
19:19:34
上传
评论
收藏 15.6MB RAR 举报
温馨提示
这是我学习使用rtaudio时写的一些例子,大家可以参考参考。在vs2015下完成的 这是我学习使用rtaudio时写的一些例子,大家可以参考参考。在vs2015下完成的
资源推荐
资源详情
资源评论
收起资源包目录
rtaudio学习Demo (117个子文件)
RtAudio.cpp 357KB
RtAudio.cpp 357KB
RtAudio.cpp 357KB
RtAudio.cpp 357KB
RtAudio.cpp 357KB
pcm2wav.cpp 5KB
firstMain.cpp 4KB
recordMain.cpp 3KB
realTimePlayBackMain.cpp 2KB
pcmPlayerMain.cpp 561B
newRecordMain.cpp 339B
newRecord.exe 264KB
realtimeplayback.exe 244KB
rtaudio.exe 244KB
record.exe 243KB
pcmPlayer.exe 240KB
newRecord.vcxproj.filters 1KB
pcmPlayer.vcxproj.filters 1KB
realtimeplayback.vcxproj.filters 1KB
record.vcxproj.filters 1KB
rtaudio.vcxproj.filters 1KB
RtAudio.h 46KB
RtAudio.h 46KB
RtAudio.h 46KB
RtAudio.h 46KB
RtAudio.h 46KB
record.h 5KB
pcmplayer.h 3KB
pcm2wav.h 3KB
pcmaudio.h 2KB
pcmaudio.h 983B
scopeguard.h 804B
scopeguard.h 804B
vc140.idb 1.07MB
vc140.idb 1.06MB
vc140.idb 1.04MB
vc140.idb 947KB
vc140.idb 947KB
pcmPlayer.ilk 1MB
newRecord.ilk 1004KB
rtaudio.ilk 828KB
record.ilk 808KB
realtimeplayback.ilk 796KB
pcmPlayer.lastbuildstate 155B
newRecord.lastbuildstate 155B
rtaudio.lastbuildstate 155B
realtimeplayback.lastbuildstate 155B
record.lastbuildstate 155B
record.log 2KB
newRecord.log 1KB
realtimeplayback.log 1KB
pcmPlayer.log 1KB
rtaudio.log 1KB
RtAudio.obj 879KB
RtAudio.obj 879KB
RtAudio.obj 879KB
RtAudio.obj 874KB
RtAudio.obj 874KB
newRecordMain.obj 278KB
pcm2wav.obj 161KB
firstMain.obj 150KB
pcmPlayerMain.obj 95KB
realTimePlayBackMain.obj 90KB
recordMain.obj 88KB
newRecord.pdb 2.56MB
pcmPlayer.pdb 2MB
rtaudio.pdb 1.82MB
record.pdb 1.79MB
realtimeplayback.pdb 1.59MB
vc140.pdb 716KB
vc140.pdb 684KB
vc140.pdb 684KB
vc140.pdb 676KB
vc140.pdb 668KB
record.raw 689KB
record.raw 689KB
record.raw 345KB
record.raw 345KB
rtaudio.sdf 44.31MB
rtaudio.sln 4KB
.suo 64KB
CL.read.1.tlog 80KB
CL.read.1.tlog 54KB
CL.read.1.tlog 54KB
CL.read.1.tlog 54KB
CL.read.1.tlog 54KB
link.read.1.tlog 3KB
link.read.1.tlog 3KB
link.read.1.tlog 3KB
link.read.1.tlog 3KB
link.read.1.tlog 3KB
CL.command.1.tlog 2KB
CL.write.1.tlog 2KB
CL.command.1.tlog 1KB
CL.write.1.tlog 1KB
CL.command.1.tlog 1KB
link.command.1.tlog 1KB
link.command.1.tlog 1KB
CL.write.1.tlog 1KB
CL.command.1.tlog 1KB
共 117 条
- 1
- 2
资源评论
- Im-JC2018-07-11vs17没有编过
- fffff56782018-10-16例子还可以,不过有些地方不是很详细。我使用mingw拷贝部分代码编译成功
- chuishazuoshi2021-01-22试了还行,还得自己调试一下
- ccwRadar2018-05-19怎么是病毒文件啊????????
芥末的无奈
- 粉丝: 839
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功