![]() I created a simple activity contains 2 buttons, every time i start clicking randomly on the buttons (even when slow clicking), the app crashes when the total clicks reach exactly 30 clicks. is_playing (): pass # Do something useful in here (e.g. These sequences are designed to help people with tinnitus. play ( frequency, step_duration, amplitude ) while generator. log ( frequency_end, 10 ), num_frequencies ): print ( "Playing tone at Hz". Step_duration = 0.43 # Time (seconds) to play at each stepįor frequency in numpy. Num_frequencies = 200 # Number of frequencies in the sweepĪmplitude = 0.50 # Amplitude of the waveform Generator = ToneGenerator () frequency_start = 50 # Frequency to start the sweep fromįrequency_end = 10000 # Frequency to end the sweep at frames_per_buffer, stream_callback = self. samplerate, output = True, frames_per_buffer = self. streamOpen = False return False def play ( self, frequency, duration, amplitude ): self. is_active (): return True else : if self. paComplete ) def is_playing ( self ): if self. paContinue ) else : return ( None, pyaudio. frames_per_buffer return out def callback ( self, in_data, frame_count, time_info, status ): if self. frames_per_buffer - len ( tmp ))) else : xs = numpy. x_max : # We don't need a full buffer or audio so pad the end with 0's streamOpen = False def sinewave ( self ): if self. the Tone Generator tool with the Sine waveform and an amplitude of 0.8. frames_per_buffer = frames_per_buffer self. A step of 50 could result in the following sequence: 100 Hz 150 Hz 200 Hz. Import numpy import pyaudio import math class ToneGenerator ( object ): def _init_ ( self, samplerate = 44100, frames_per_buffer = 4410 ): self. play ( frequency, duration, amplitude ) If you just need to play one particular frequency you can substitute the usage example for (remember to enter your own frequency, duration, and amplitude) generator = ToneGenerator () generator. It doesn’t create smooth waveform transitions between each frequency step so you’ll hear pops whenever the frequency changes. Sometimes it can take a while before it starts playing. ![]() On Ubuntu: sudo apt-get install python-pyaudio Make sure you’ve installed pyaudio to make this run. This script generates a frequency sweep from 50 Hz to 10 kHz and is easily adjustable. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |