2013-06-12 22 views
0

我需要一個C++ API來枚舉輸入設備併爲Windows Vista,Windows 7和Windows 8捕獲聲音。如果沒有公共API,則可以針對不同版本的Windows使用特定於OS的API。用於在Windows上捕獲聲音的API

我在微軟網站上發現了一些參考文獻,但我不知道該選什麼。你有什麼建議?

+1

嗯,這取決於你想用什麼做的: waveIn API,Core Audio API(在XP上不可用),DirectShow? – user1764961

+0

@ user1764961我不想使用特定的東西。現在我處於「研究」階段,我需要選擇一個,但我不知道要選擇什麼。 – Felics

+0

Steinberg的ASIO API超出或無法做到這一點。 – ChiefTwoPencils

回答

1

看看BASS library

正是:

  • 跨平臺;
  • well documented;
  • 有很大的支持;
  • 易於使用;
  • 有很多插件;
  • 免費用於非商業用途

獲取錄音設備的總數目前存在:

int a, count=0; 
BASS_DEVICEINFO info; 
for (a=0; BASS_RecordGetDeviceInfo(a, &info); a++) 
    if (info.flags&BASS_DEVICE_ENABLED) // device is enabled 
     count++; // count it 

開始在44100hz 16位立體聲錄音:

FILE *file; 
... 
// the recording callback 
BOOL CALLBACK MyRecordingWriter(HRECORD handle, void *buf, DWORD len, void *user) 
{ 
    fwrite(buf, 1, len, file); // write the buffer to the file 
    return TRUE; // continue recording 
} 
... 
HRECORD record=BASS_RecordStart(44100, 2, 0, MyRecordingWriter, 0); // start recording