簡體   English   中英

如何使用 JMF 錄制音頻設備?

[英]How to record audio device with JMF?

因此,對於我要從計算機的麥克風錄制音頻,我需要使用CaptureDeviceManager來返回計算機系統上安裝的可用設備的列表。 這可以通過調用getDeviceList(Format format)來實現。 但是,要創建 Format 的實例,我需要在構造函數new Format(String encoding)中指定一個編碼字符串。 我不確定該編碼是什么,因為我只想返回所有可用設備的列表。 getDeviceList() 方法返回一個空向量。

API 也提到了 getDeviceList(Format format) 方法:

 If no Format is specified, this method returns a list of CaptureDeviceInfo 
 objects for all of the available capture devices.

但是,只有一個 getDeviceList() 方法需要格式。

我不知道 JMF 是您想在這里使用的工具。 也許有關於你的上下文的信息是相關的。 JMF 是相當古老的技術。 如果您想使用 Java 檢查音頻資源,主要技術在教程訪問音頻系統資源中進行了說明。

本教程包含一個代碼示例,用於檢查端口/線路以查看它們是否支持麥克風。 javax.sound.sampled.AudioSystem class 公開的方法廣泛而靈活。

你可以先用

Vector devs = CaptureDeviceManager.getDeviceList(null)

然后你可以使用

devs = CaptureDeviceManager.getDeviceList(fmts);

fmts 在哪里

AudioFormat fmts=getAudioFormat();

private AudioFormat getAudioFormat() {
    double sampleRate = 44100;
    int sampleSizeInBits = 16;
    int channels = 2;
    boolean signed = true;
    boolean bigEndian = true;
    return new AudioFormat(AudioFormat.LINEAR, sampleRate, sampleSizeInBits, channels); 
  }

它曾經為我工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM