
    &h                     H   S r SSKrSSKrSSKJrJrJrJr  SSK	J
r
  \R                  R                  SSSS5        \R                  " 5         \" S	5      r\" \5        / r/ rS
 rS r\
" \5        \" \S   S	S\SS\\S9r\R+                  S5        \" \5        \" S\S    S35        \R,                  " S5        \" S5        \R                  R/                  SR1                  \5      S9r\" S5        \R5                  5         \R,                  " S5        \R6                  " 5         g)zvpygame.examples.audiocapture

A pygame 2 experiment.

* record sound from a microphone
* play back the recorded sound
    N)get_audio_device_namesAudioDevice	AUDIO_F32AUDIO_ALLOW_FORMAT_CHANGE)set_post_mixiD         i   Tc                 @    [         R                  [        U5      5        g)zlThis is called in the sound thread.

Note, that the frequency and such you request may not be what you get.
N)sound_chunksappendbytes)audiodeviceaudiomemoryviews     T/var/www/auris/envauris/lib/python3.13/site-packages/pygame/examples/audiocapture.pycallbackr       s     o./    c                 V    [        [        U5      [        U5      5        [        U 5        g)zLThis is called in the sound thread.

At the end of mixing we get this data.
N)printtypelen)postmixr   s     r   postmix_callbackr   *   s    
 
$
_!56	'Nr   )
devicename	iscapture	frequencyaudioformatnumchannels	chunksizeallowed_changesr   zrecording with ''   z"Turning data into a pg.mixer.Soundr   )bufferzplaying back recorded sound)__doc__pygamepgtimepygame._sdl2r   r   r   r   pygame._sdl2.mixerr   mixerpre_initinitnamesr   soundsr   r   r   audiopausesleepSoundjoinsoundplayquit r   r   <module>r7      s      ,   %Q $ 	 	t$ e	0  Qx-		 A e q
!$ % 

1 * +
chh|45 # $ 

 

1 	r   