Python Forum
Can PyAudio (Port Audio) validly accept float values when writing to stream?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can PyAudio (Port Audio) validly accept float values when writing to stream?
#1
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:

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)
Reply
#2
Could it be because you're writing the same data to the stream twice? Once just after adding it to the buffer, and then again when you shift it off the buffer.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python calculate float plus float is incorrect? sirocawa 6 293 Apr-16-2024, 01:45 PM
Last Post: DeaD_EyE
  501 Server cannot accept argument anna17 0 194 Apr-11-2024, 01:08 AM
Last Post: anna17
  How to accept facebook cookies using python selenium? pablo86ad 0 202 Apr-06-2024, 09:19 PM
Last Post: pablo86ad
  pyaudio seems to randomly halt input. elpidiovaldez5 2 383 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  Microphone stream manipulation Talking2442 1 2,744 Nov-19-2023, 02:08 PM
Last Post: palumanic
  Capturing BS4 values into DF and writing to CSV cubangt 18 1,968 Sep-05-2023, 01:57 PM
Last Post: cubangt
  EEG stream data with mne and brainfolw PaulC 0 492 Aug-22-2023, 03:17 AM
Last Post: PaulC
  Write Null values as 0.0 (float) type in csv mg24 3 1,377 Dec-07-2022, 09:04 PM
Last Post: deanhystad
  accept command line argument mg24 5 1,333 Sep-27-2022, 05:58 PM
Last Post: snippsat
  formatting float like int for whole values Skaperen 8 1,757 Apr-11-2022, 01:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020