当我从iphone录制音频时如下:
//Setup the dictionary object with all the recording settings that this
//Recording sessoin will use
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
//Now that we have our settings we are going to instanciate an instance of our recorder instance.
//Generate a temp file for use by the recording.
NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
NSString *caldate = [now description];
recordedTmpFile = [[NSString stringWithFormat:@"%@/%@.caf", DOCUMENTS_FOLDER, caldate] retain];
NSLog(@"Using …Run Code Online (Sandbox Code Playgroud) 我创建了一个从客户端接收声音的服务器应用程序,然后我广播这个存储为字节的声音,并将字节发送回连接到服务器的客户端.现在我只使用一个客户端进行测试,而客户端正在接收语音,但声音一直都是口吃.有人可以告诉我我做错了什么吗?
我想我理解为什么声音播放不顺畅但不明白如何解决问题.
代码是吼叫.
客户端:
public void captureAudio()
{
Runnable runnable = new Runnable(){
public void run()
{
first=true;
try {
final AudioFileFormat.Type fileType = AudioFileFormat.Type.AU;
final AudioFormat format = getFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
line = (TargetDataLine)AudioSystem.getLine(info);
line.open(format);
line.start();
int bufferSize = (int) format.getSampleRate()* format.getFrameSize();
byte buffer[] = new byte[bufferSize];
out = new ByteArrayOutputStream();
objectOutputStream = new BufferedOutputStream(socket.getOutputStream());
running = true;
try {
while (running) {
int count = line.read(buffer, 0, buffer.length);
if (count > 0) { …Run Code Online (Sandbox Code Playgroud) 我试图创建一个音频缓冲区并将他发送到一个新类.在这个类中,我将使用AudioTracker播放此缓冲区,但它不起作用.我可以按时听到声音,但声音就像一个halleffect.我没有想到我的错误,也没有找到这个问题的答案.我希望你能帮助我.(对不起,我的英语不是最好的)Sorcecode:
public class input {
private static final String TAG = "Aufnahme";
private AudioRecord recorder = null;
private boolean isRecording = false;
private int SAMPLERATE = 8000;
private int CHANNELS = AudioFormat.CHANNEL_CONFIGURATION_MONO;
private int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
private int bufferSize = AudioRecord.getMinBufferSize(SAMPLERATE, CHANNELS,
AUDIO_FORMAT);
private Thread recordingThread = null;
public void startRecording() {
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, SAMPLERATE,
CHANNELS, AUDIO_FORMAT, bufferSize);
recorder.startRecording();
isRecording = true;
recordingThread = new Thread(new Runnable()
{
public void run() {
writeAudioData();
}
});
recordingThread.start();
} …Run Code Online (Sandbox Code Playgroud) 如何在Android 2.2中使用MediaRecorder 录制M4A 音频文件?
我需要设置什么输出格式,编码器和采样率?
我需要从麦克风录制它并将其保存在SDCARD中
UPDATE
我试过这段代码,但结果无效(例如在浏览器中没有播放):
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); // error here ?!?
recorder.setAudioSamplingRate(96000); // what value ?
Run Code Online (Sandbox Code Playgroud) 当我使用Androids AudioRecord从麦克风录制时,我得到了这个令人讨厌的神器

有没有办法避免或删除这个?它是什么?或者我得到了,因为我在配置中做错了(但其他一切正常).
这是我的AudioRecord配置:
sampleRateInHz = 44100;
channelConfigRec = AudioFormat.CHANNEL_IN_MONO;
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
bufferSizeInBytesRec = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfigRec, audioFormat);
audioSource = AudioSource.MIC;
Run Code Online (Sandbox Code Playgroud)
我很确定我的代码是正确的,因为我可以记录所有内容,但是在开头就有这样的点击.
我正在尝试实现AudioTrack来检索我的android设备中的音频,以接收来自IAX的来电,但过一会儿遇到异常。
private void writeBuff(short[] buf) {
try {
if (this.track == null) {
Log.w("IAX2Audio", "write() without an AudioTrack");
return;
}
int written = 0;
while (written < buf.length) {
if (this.track != null) {
int res;
res = this.track.write(buf, written, buf.length - written);
switch (res) {
case AudioTrack.ERROR_INVALID_OPERATION:
Log.e("IAX2Audio", "Invalid write()");
return;
case AudioTrack.ERROR_BAD_VALUE:
Log.e("IAX2Audio", "Bad arguments to write()");
return;
}
written += res;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
例外在这里
04-27 18:26:15.865: W/System.err(12681): java.lang.IllegalStateException: Unable …Run Code Online (Sandbox Code Playgroud) android audio-recording audiotrack android-audiomanager android-audiorecord
我开发了一个带有实时视频流的iOS应用程序.我将音频采样率固定为8k.音频在iPhone6设备上运行良好,但是当我在6s和6s中流式传输视频时,音频部分无效.我该如何解决这个问题?我尝试在不同的博客中发现,在iPhone 6s中,采样率锁定在48k.我该如何手动下采样?因为我用于直播的图书馆只能用于8k.请帮我解决这些问题
我正在swift构建一个iOS应用程序,客户端返回了录音的问题,基本上它没有记录任何内容.他在带有ios 9.x的iPhone 5/5s上进行了测试.检查权限,如果手机上有足够的空间,这些都不是问题.
就个人而言,在模拟器上使用带有ios 10.x和iphone 5的iphone 6s设备测试并且记录正在运行.任何人之前遇到过这种情况,或者说我做错了什么让我望而却步.
为不同的功能添加了注释,说明应用程序的功能.
protocol RecordAndPlayManagerDelegate : class{
func recorderDidStopRecording()
}
class RecordAndPlayManager: NSObject, AVAudioRecorderDelegate {
var soundRecorder: AVAudioRecorder!
let recordSettings = [
AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
AVSampleRateKey: 12000,
AVNumberOfChannelsKey: 1,
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
]
class func directoryURL() -> URL? {
let fileManager = FileManager.default
let urls = fileManager.urls(for: .documentDirectory, in: .userDomainMask)
let documentDirectory = urls[0] as URL
let soundURL = documentDirectory.appendingPathComponent("recording.m4a")
return soundURL
}
//calling this from outside to get the audio
class func getLocalOrRemoteRecording(_ recordingID : String!) …Run Code Online (Sandbox Code Playgroud) 所以,我有一个应用程序,当连接到汽车的HFP时,需要使用汽车的麦克风.它在没有BT的情况下工作正常,它可以与BT耳机一起使用,但不适用于HFP - 当它连接到我的汽车的BT时它使用HFP扬声器但不使用麦克风.
我究竟做错了什么?这是Android的bug吗?
private static boolean isBluetoothHeadsetConnected() {
BluetoothAdapter mBluetoothAdapter =
BluetoothAdapter.getDefaultAdapter();
return mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()
&&
mBluetoothAdapter.getProfileConnectionState(BluetoothHeadset.HEADSET) ==
BluetoothHeadset.STATE_CONNECTED;
}
private boolean checkBlueTooth() {
if (!isBluetoothHeadsetConnected()) {
return false;
}
return true;
}
private void useBluetooth() {
AudioManager audioManager;
audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.startBluetoothSco();
audioManager.setBluetoothScoOn(true);
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (checkBlueTooth()) {
start();
} else {
BroadcastReceiver scoReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if …Run Code Online (Sandbox Code Playgroud) android bluetooth audio-recording android-audiomanager android-bluetooth
audio-recording ×10
android ×6
ios ×4
iphone ×4
audio ×3
java ×2
audiotrack ×1
bluetooth ×1
jailbreak ×1
m4a ×1
objective-c ×1
sample-rate ×1
sockets ×1
swift ×1
tcp ×1