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
  pyaudio seems to randomly halt input. elpidiovaldez5 2 312 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  Microphone stream manipulation Talking2442 1 2,682 Nov-19-2023, 02:08 PM
Last Post: palumanic
  Capturing BS4 values into DF and writing to CSV cubangt 18 1,851 Sep-05-2023, 01:57 PM
Last Post: cubangt
  EEG stream data with mne and brainfolw PaulC 0 462 Aug-22-2023, 03:17 AM
Last Post: PaulC
  Write Null values as 0.0 (float) type in csv mg24 3 1,312 Dec-07-2022, 09:04 PM
Last Post: deanhystad
  accept command line argument mg24 5 1,241 Sep-27-2022, 05:58 PM
Last Post: snippsat
  formatting float like int for whole values Skaperen 8 1,674 Apr-11-2022, 01:56 PM
Last Post: deanhystad
  Float Slider - Affecting Values in Column 'Pandas' planckepoch86 0 1,370 Jan-22-2022, 02:18 PM
Last Post: planckepoch86
  is there a way to mention port range or search for port dynamically with qConnection Creepy 0 1,450 Sep-09-2021, 03:15 PM
Last Post: Creepy
  Not getting response from pyaudio OceansBlue 1 2,584 Jul-03-2021, 06:22 AM
Last Post: OceansBlue

Forum Jump:

User Panel Messages

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