google-code-export / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Pitch change functionality with pulseaudio driver. #536

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Purpose of code changes on this branch:
set_pitch method of PulseAudioPlayer in media/drivers/pulse/__init__.py has 
been implemented.

After the review, I'll merge this branch into:
/trunk

Here's the diff from mercurial:

diff -r 4ce991e689f8 pyglet/media/drivers/pulse/__init__.py
--- a/pyglet/media/drivers/pulse/__init__.py    Sat Aug 20 17:02:53 2011 +0200
+++ b/pyglet/media/drivers/pulse/__init__.py    Mon Sep 19 17:05:05 2011 +0100
@@ -202,6 +202,7 @@
         sample_spec.rate = audio_format.sample_rate
         sample_spec.channels = audio_format.channels
         channel_map = None
+        self.sample_rate = audio_format.sample_rate

         try:
             context.lock()
@@ -233,7 +234,8 @@
             device = None
             buffer_attr = None
             flags = (pa.PA_STREAM_START_CORKED |
-                     pa.PA_STREAM_INTERPOLATE_TIMING)
+                     pa.PA_STREAM_INTERPOLATE_TIMING |
+                     pa.PA_STREAM_VARIABLE_RATE)

             sync_stream = None  # TODO use this
             check(
@@ -537,8 +539,11 @@
         context.unlock()

     def set_pitch(self, pitch):
-        # XXX TODO (pa_stream_update_sample_rate)
-        pass
+        pa.pa_stream_update_sample_rate(self.stream,
+                                        int(pitch*self.sample_rate),
+                                        self._success_cb_func,
+                                        None)
+                                        

 def create_audio_driver():
     global context

Original issue reported on code.google.com by Adam.JT...@gmail.com on 19 Sep 2011 at 4:06

GoogleCodeExporter commented 9 years ago
Applied, thanks!

Original comment by r1chardj0n3s on 28 Oct 2011 at 2:36