mirror of
https://github.com/larsimmisch/pyalsaaudio.git
synced 2026-06-01 19:07:02 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3aa602a04 | |||
| 046e7c4e87 | |||
| a4c4c7cb62 | |||
| f478797f6f | |||
| 12f807698a | |||
| fc011b5ea6 | |||
| f244a70111 | |||
| a056a90c61 | |||
| be1b3e131d | |||
| 8abf06bedf | |||
| dcc831e607 | |||
| e587df9143 | |||
| 82febd3f7e | |||
| 1695066c11 | |||
| 25717020ef | |||
| 1aae655d24 | |||
| c1c8362eb2 | |||
| 723eff3887 | |||
| aa9867de18 | |||
| 58f4522769 | |||
| f2fb61d324 | |||
| 9e79494a95 |
@@ -1,3 +1,32 @@
|
||||
Version 0.8.6:
|
||||
- Added four methods to the 'PCM' class to allow users to get detailed information about the device:
|
||||
|
||||
- 'getformats()' returns a dictionary of name / value pairs, one for each of the card's
|
||||
supported formats - e.g. '{"U8": 1, "S16_LE": 2}',
|
||||
- 'getchannels()' returns a list of the supported channel numbers, e.g. '[1, 2]',
|
||||
- 'getrates()' returns supported sample rates for the device, e.g. '[48000]',
|
||||
- 'getratebounds()' returns the device's official minimum and maximum supported
|
||||
sample rates as a tuple, e.g. '(4000, 48000)'.
|
||||
|
||||
(#82 contributed by @jdstmporter)
|
||||
|
||||
- Prevent hang on close after capturing audio (#80 contributed by @daym)
|
||||
|
||||
Version 0.8.5:
|
||||
- Return an empty string/bytestring when 'read()' detects an
|
||||
overrun. Previously the returned data was undefined (contributed by @jcea)
|
||||
|
||||
- Unlimited setperiod buffer size when reading frames (contributed by @jcea)
|
||||
|
||||
Version 0.8.4:
|
||||
- Fix Python3 API usage broken in 0.8.3
|
||||
|
||||
Version 0.8.3:
|
||||
- Add DSD sample formats (contributed by @lintweaker)
|
||||
- Add Mixer.handleevents() to acknowledge events identified by select.poll (contributed by @PaulSD)
|
||||
- Add functions for listing cards and their names (contributed by @chrisdiamand)
|
||||
- Add a method for setting enums (contributed by @chrisdiamand)
|
||||
|
||||
Version 0.8.2:
|
||||
- fix #3 (we cannot get the revision from git for pip installs)
|
||||
|
||||
|
||||
+404
-373
File diff suppressed because it is too large
Load Diff
+9
-13
@@ -443,35 +443,31 @@ Mixer objects have the following methods:
|
||||
This method will fail if the mixer has no capture switch capabilities.
|
||||
|
||||
|
||||
.. method:: Mixer.getvolume(direction=PCM_PLAYBACK, unit=Percent)
|
||||
.. method:: Mixer.getvolume([direction])
|
||||
|
||||
Returns a list with the current volume settings for each channel. The list
|
||||
elements are percentages or dB values, depending on *unit*.
|
||||
elements are integer percentages.
|
||||
|
||||
The *direction* argument can be either :const:`PCM_PLAYBACK` or
|
||||
The optional *direction* argument can be either :const:`PCM_PLAYBACK` or
|
||||
:const:`PCM_CAPTURE`, which is relevant if the mixer can control both
|
||||
playback and capture volume. The default value is :const:`PCM_PLAYBACK`
|
||||
if the mixer has playback channels, otherwise it is :const:`PCM_CAPTURE`.
|
||||
|
||||
|
||||
.. method:: Mixer.setvolume(volume, channel=MIXER_CHANNEL_ALL, direction=PCM_PLAYBACK, unit=Percent)
|
||||
.. method:: Mixer.setvolume(volume, [channel], [direction])
|
||||
|
||||
Change the current volume settings for this mixer. The *volume* argument
|
||||
controls the new volume setting as either a percentage or a dB value. Both
|
||||
integer and floating point values can be given.
|
||||
controls the new volume setting as an integer percentage.
|
||||
|
||||
The *channel* argument can be used to restrict the channels for which the volume is
|
||||
set. By default, the volume of all channels is adjusted. This assumes that the mixer
|
||||
can control the volume for the channels independently.
|
||||
If the optional argument *channel* is present, the volume is set
|
||||
only for this channel. This assumes that the mixer can control the
|
||||
volume for the channels independently.
|
||||
|
||||
The *direction* argument can be either :const:`PCM_PLAYBACK` or
|
||||
The optional *direction* argument can be either :const:`PCM_PLAYBACK` or
|
||||
:const:`PCM_CAPTURE`, which is relevant if the mixer can control both
|
||||
playback and capture volume. The default value is :const:`PCM_PLAYBACK`
|
||||
if the mixer has playback channels, otherwise it is :const:`PCM_CAPTURE`.
|
||||
|
||||
The *unit* argument determines how the volume value is interpreted, as a prcentage
|
||||
or as a dB value.
|
||||
|
||||
.. method:: Mixer.setmute(mute, [channel])
|
||||
|
||||
Sets the mute flag to a new value. The *mute* argument is either 0 for not
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ development at the time - and neither are very feature complete.
|
||||
I wrote PyAlsaAudio to fill this gap. My long term goal is to have the module
|
||||
included in the standard Python library, but that looks currently unlikely.
|
||||
|
||||
PyAlsaAudio hass full support for sound capture, playback of sound, as well as
|
||||
PyAlsaAudio has full support for sound capture, playback of sound, as well as
|
||||
the ALSA Mixer API.
|
||||
|
||||
MIDI support is not available, and since I don't own any MIDI hardware, it's
|
||||
|
||||
+7
-11
@@ -46,17 +46,13 @@ def show_mixer(name, kwargs):
|
||||
print("Capabilities: %s %s" % (' '.join(mixer.volumecap()),
|
||||
' '.join(mixer.switchcap())))
|
||||
volumes = mixer.getvolume()
|
||||
for i, v in enumerate(volumes):
|
||||
print("Channel %i volume: %.02f%%" % (i, v))
|
||||
|
||||
volumes = mixer.getvolume(unit=alsaaudio.dB)
|
||||
for i, v in enumerate(volumes):
|
||||
print("Channel %i volume: %.02fdB" % (i, v))
|
||||
|
||||
for i in range(len(volumes)):
|
||||
print("Channel %i volume: %i%%" % (i,volumes[i]))
|
||||
|
||||
try:
|
||||
mutes = mixer.getmute()
|
||||
for i, m in enumerate(mutes):
|
||||
if m:
|
||||
for i in range(len(mutes)):
|
||||
if mutes[i]:
|
||||
print("Channel %i is muted" % i)
|
||||
except alsaaudio.ALSAAudioError:
|
||||
# May not support muting
|
||||
@@ -64,8 +60,8 @@ def show_mixer(name, kwargs):
|
||||
|
||||
try:
|
||||
recs = mixer.getrec()
|
||||
for i, r in enumerate(recs):
|
||||
if r:
|
||||
for i in range(len(recs)):
|
||||
if recs[i]:
|
||||
print("Channel %i is recording" % i)
|
||||
except alsaaudio.ALSAAudioError:
|
||||
# May not support recording
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ def play(device, f):
|
||||
else:
|
||||
raise ValueError('Unsupported format')
|
||||
|
||||
periodsize = f.getframerate() / 8
|
||||
periodsize = f.getframerate() // 8
|
||||
|
||||
device.setperiodsize(periodsize)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user