Mar-24-2017, 11:19 PM
I am trying to send over audio data from an iOS device and send it to another device which is using PyAudio to play the sound.
I have been able to successfully do this from python device to python device, but now I am trying to get iOS device to python device.
The issue I am having at the moment is when capturing audio data on iOS I get an array of float values. When I transfer the data and play it with PyAudio I just get a bunch of feedback.
Now I am wondering can PyAudio handle float values at all? How could I properly handle float data for audio that PyAudio can play it properly or do I need to change the format.
How I am currently getting the audio:
[Objective-C]
Novocaine *audioManager = [Novocaine audioManager];
[audioManager setInputBlock:^(float *newAudio, UInt32 numSamples, UInt32 numChannels) {
// Now you're getting audio from the microphone every 20 milliseconds or so. How's that for easy?
// Audio comes in interleaved, so,
// if numChannels = 2, newAudio[0] is channel 1, newAudio[1] is channel 2, newAudio[2] is channel 1, etc.
}];
[audioManager play];
[/Objective-C]
How I am trying to play the audio:
I have been able to successfully do this from python device to python device, but now I am trying to get iOS device to python device.
The issue I am having at the moment is when capturing audio data on iOS I get an array of float values. When I transfer the data and play it with PyAudio I just get a bunch of feedback.
Now I am wondering can PyAudio handle float values at all? How could I properly handle float data for audio that PyAudio can play it properly or do I need to change the format.
How I am currently getting the audio:
[Objective-C]
Novocaine *audioManager = [Novocaine audioManager];
[audioManager setInputBlock:^(float *newAudio, UInt32 numSamples, UInt32 numChannels) {
// Now you're getting audio from the microphone every 20 milliseconds or so. How's that for easy?
// Audio comes in interleaved, so,
// if numChannels = 2, newAudio[0] is channel 1, newAudio[1] is channel 2, newAudio[2] is channel 1, etc.
}];
[audioManager play];
[/Objective-C]
How I am trying to play the audio:
def audioStream_ios(payload): if stream.is_active(): # print payload self.buffer += payload stream.write(payload) yield self.subscribe(audioStream_ios, 'com.app.audioStream_ios') while 1: if stream.is_active() and len(self.buffer) >= CHUNK * 1: data = self.buffer[:CHUNK] self.buffer = self.buffer[CHUNK:] print 'write' stream.write(data) yield sleep(0.01)