-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for release 4.0.8, including new python binding, new teststop…
…s.cpp program, ALSA "default" flag, and various changes to stopping behavior (GS).
- Loading branch information
1 parent
24a98a1
commit 6faf433
Showing
19 changed files
with
9,271 additions
and
7,944 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
import rtaudio as rt | ||
|
||
from math import cos | ||
|
||
import struct | ||
|
||
|
||
class audio_generator: | ||
def __init__(self): | ||
self.idx = -1 | ||
self.freq = 440. | ||
def __call__(self): | ||
self.idx += 1 | ||
if self.idx%48000 == 0: | ||
self.freq *= 2**(1/12.) | ||
return 0.5*cos(2.*3.1416*self.freq*self.idx/48000.) | ||
|
||
|
||
class callback: | ||
def __init__(self, gen): | ||
self.gen = gen | ||
self.i = 0 | ||
def __call__(self,playback, capture): | ||
[struct.pack_into("f", playback, 4*o, self.gen()) for o in xrange(256)] | ||
self.i = self.i + 256 | ||
if self.i > 48000*10: | ||
print '.' | ||
return 1 | ||
|
||
dac = rt.RtAudio() | ||
|
||
n = dac.getDeviceCount() | ||
print 'Number of devices available: ', n | ||
|
||
for i in range(n): | ||
try: | ||
print dac.getDeviceInfo(i) | ||
except rt.RtError as e: | ||
print e | ||
|
||
|
||
print 'Default output device: ', dac.getDefaultOutputDevice() | ||
print 'Default input device: ', dac.getDefaultInputDevice() | ||
|
||
print 'is stream open: ', dac.isStreamOpen() | ||
print 'is stream running: ', dac.isStreamRunning() | ||
|
||
oParams = {'deviceId': 1, 'nChannels': 1, 'firstChannel': 0} | ||
iParams = {'deviceId': 1, 'nChannels': 1, 'firstChannel': 0} | ||
|
||
try: | ||
dac.openStream(oParams,oParams,48000,256,callback(audio_generator()) ) | ||
except rt.RtError as e: | ||
print e | ||
else: | ||
dac.startStream() | ||
|
||
import time | ||
print 'latency: ', dac.getStreamLatency() | ||
|
||
while (dac.isStreamRunning()): | ||
time.sleep(0.1) | ||
|
||
print dac.getStreamTime() | ||
|
||
dac.stopStream() | ||
dac.abortStream() | ||
dac.closeStream() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
PyRtAudio - a python wrapper around RtAudio that allows to perform audio i/o operations in real-time from the python language. | ||
|
||
By Antoine Lefebvre, 2011 | ||
|
||
This software is in the development stage. Do not expect compatibility | ||
with future versions. Comments, suggestions, new features, bug fixes, | ||
etc. are welcome. | ||
|
||
|
||
This distribution of PyRtAudio contains the following: | ||
|
||
- rtaudiomodule.cpp: the python wrapper code | ||
- setup.py: a setup script use to compile and install PyRtAudio | ||
- examples: a single PyRtAudioTest.py script | ||
|
||
INSTALLATION | ||
|
||
The compilation and installation of the PyRtAudio module is handled by | ||
the python Distribution Utilities ("Distutils"). Provided that your | ||
system has a C++ compiler and is properly configure, the following | ||
command should be sufficient: | ||
|
||
>> python setup.py install | ||
|
||
Please refer to the distutils documentation for installation problems: http://docs.python.org/distutils/index.html | ||
|
||
LEGAL AND ETHICAL: | ||
|
||
The PyRtAudio license is the same as the RtAudio license: | ||
|
||
PyRtAudio: a python wrapper around RtAudio | ||
Copyright (c)2011 Antoine Lefebvre | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation files | ||
(the "Software"), to deal in the Software without restriction, | ||
including without limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of the Software, | ||
and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
Any person wishing to distribute modifications to the Software is | ||
asked to send the modifications to the original developer so that | ||
they can be incorporated into the canonical version. This is, | ||
however, not a binding provision of this license. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR | ||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
Oops, something went wrong.