Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a4b055ff
Commit
a4b055ff
authored
Apr 28, 1999
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a scale widget and command line options to set the output volume.
Bump version number 1.0
parent
c7c9a648
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
18 deletions
+65
-18
Tools/audiopy/README
Tools/audiopy/README
+18
-10
Tools/audiopy/audiopy
Tools/audiopy/audiopy
+47
-8
No files found.
Tools/audiopy/README
View file @
a4b055ff
...
...
@@ -6,10 +6,10 @@ Version: 0.1
Introduction
Audiopy is a program to control the Solaris audio device, allowing
you to
set both the input and output devices. It can be run
either as a standalone command-line script, or as a Tkinter based
GUI application.
Audiopy is a program to control the Solaris audio device, allowing
you to
choose both the input and output devices, and to set the
output volume. It can be run either as a standalone command-line
script, or as a Tkinter based
GUI application.
Note that your version of Python must have been built with the
sunaudiodev module enabled. It is not enabled by default however!
...
...
@@ -26,6 +26,8 @@ Introduction
devices: the headphone jack, the speakers, or the line-out jack.
You can enable any combination of these three devices.
You can also set the output gain (volume) level.
Running as a GUI
Simply start audiopy with no arguments to start it as a Tkinter
...
...
@@ -43,11 +45,11 @@ Running as a GUI
Alt-q is also an accelerator for selecting Quit from the File
menu.
No unsupported devices will appear in the GUI. When run as a GUI,
a
udiopy monitors the audio device and automatically updates its
display if the state of the device is changed by some other
means. In pre-
Python 1.5.2 this is done by occasionally polling
the device, but in Python 1.5.2 no polling is necessary (you don't
Unsupported devices will appear dimmed out in the GUI. When run
a
s a GUI, audiopy monitors the audio device and automatically
updates its display if the state of the device is changed by some
other means. In
Python 1.5.2 this is done by occasionally polling
the device, but in Python 1.5.2 no polling is necessary (you don't
really need to know this, but I thought I'd plug 1.5.2 :-).
Running as a Command Line Program
...
...
@@ -85,7 +87,13 @@ Running as a Command Line Program
% ./audiopy -s=0 -p=1 -c
Audiopy understands two other command line options:
Audiopy understands these other command line options:
--gain volume
-g volume
Sets the output volume to the specified gain level. This must
be an integer between MIN_GAIN and MAX_GAIN (usually [0..255],
but use the -h option to find the exact values).
--version
-v
...
...
Tools/audiopy/audiopy
View file @
a4b055ff
...
...
@@ -7,10 +7,10 @@ Email: bwarsaw@python.org
Version: %(__version__)s
When no arguments are given, this pops up a graphical window which lets you
choose the audio input and output devices.
choose the audio input and output devices
, and set the output volume
.
This program can be driven via the command line, and when done so, no window
pops up.
O
ptions have the general form:
pops up.
Most o
ptions have the general form:
--device[={0,1}]
-d[={0,1}]
...
...
@@ -31,6 +31,11 @@ The list of devices and their short options are:
Other options are:
--gain volume
-g volume
Sets the output gain to the specified volume, which must be an integer
in the range [%(MIN_GAIN)s..%(MAX_GAIN)s]
--version
-v
Print the version number and exit.
...
...
@@ -49,7 +54,7 @@ from SUNAUDIODEV import *
# Milliseconds between interrupt checks
KEEPALIVE_TIMER
=
500
__version__
=
'
0.1
'
__version__
=
'
1.0
'
...
...
@@ -213,6 +218,21 @@ class MainWindow:
root
.
bind
(
'<Alt-q>'
,
self
.
__quit
)
root
.
bind
(
'<Alt-Q>'
,
self
.
__quit
)
#
# Volume
frame
=
Frame
(
root
,
bd
=
1
,
relief
=
RAISED
)
frame
.
grid
(
row
=
3
,
column
=
0
,
sticky
=
'NSEW'
)
label
=
Label
(
frame
,
text
=
'Output Volume:'
)
label
.
grid
(
row
=
0
,
column
=
0
,
sticky
=
W
)
self
.
__scalevar
=
IntVar
()
self
.
__scale
=
Scale
(
frame
,
orient
=
HORIZONTAL
,
from_
=
MIN_GAIN
,
to
=
MAX_GAIN
,
length
=
200
,
variable
=
self
.
__scalevar
,
command
=
self
.
__volume
)
self
.
__scale
.
grid
(
row
=
1
,
column
=
0
,
sticky
=
EW
)
#
# do we need to poll for changes?
self
.
__needtopoll
=
1
try
:
...
...
@@ -268,6 +288,8 @@ Email: bwarsaw@python.org''' % __version__)
self
.
__spkvar
.
set
(
info
.
o_port
&
SPEAKER
)
self
.
__headvar
.
set
(
info
.
o_port
&
HEADPHONE
)
self
.
__linevar
.
set
(
info
.
o_port
&
LINE_OUT
)
# volume
self
.
__scalevar
.
set
(
info
.
o_gain
)
def
__pushtodev
(
self
,
event
=
None
):
info
=
self
.
__devctl
.
getinfo
()
...
...
@@ -275,6 +297,7 @@ Email: bwarsaw@python.org''' % __version__)
self
.
__headvar
.
get
()
+
\
self
.
__linevar
.
get
()
info
.
i_port
=
self
.
__inputvar
.
get
()
info
.
o_gain
=
self
.
__scalevar
.
get
()
self
.
__devctl
.
setinfo
(
info
)
def
__getset
(
self
,
var
,
onvalue
):
...
...
@@ -306,6 +329,9 @@ Email: bwarsaw@python.org''' % __version__)
def
__lineout
(
self
,
event
=
None
):
self
.
__getset
(
self
.
__linevar
,
LINE_OUT
)
def
__volume
(
self
,
event
=
None
):
self
.
__pushtodev
()
def
start
(
self
):
self
.
__keepalive
()
self
.
__tkroot
.
mainloop
()
...
...
@@ -361,7 +387,7 @@ class Helpwin:
def
usage
(
msg
=
''
,
code
=
1
):
def
usage
(
code
,
msg
=
''
):
print
__doc__
%
globals
()
if
msg
:
print
msg
...
...
@@ -398,10 +424,23 @@ def main():
info
=
device
.
getinfo
()
# first get the existing values
for
arg
in
sys
.
argv
[
1
:]:
i
=
0
while
i
<
len
(
sys
.
argv
)
-
1
:
i
=
i
+
1
arg
=
sys
.
argv
[
i
]
if
arg
in
(
'-h'
,
'--help'
):
usage
(
code
=
0
)
usage
(
0
)
# does not return
elif
arg
in
(
'-g'
,
'--gain'
):
gainspec
=
'<missing>'
try
:
gainspec
=
sys
.
argv
[
i
+
1
]
gain
=
int
(
gainspec
)
except
(
ValueError
,
IndexError
):
usage
(
1
,
'Bad gain specification: '
+
gainspec
)
info
.
o_gain
=
gain
i
=
i
+
1
continue
elif
arg
in
(
'-v'
,
'--version'
):
print
'''
\
audiopy -- a program to control the Solaris audio device.
...
...
@@ -424,7 +463,7 @@ Version: %s''' % __version__
elif
arg
[:
len
(
short
)
+
1
]
==
short
+
'='
:
val
=
int
(
arg
[
len
(
short
)
+
1
:])
except
ValueError
:
usage
(
msg
=
'Invalid option: '
+
arg
)
usage
(
1
,
msg
=
'Invalid option: '
+
arg
)
# does not return
if
val
==
0
:
if
io
==
0
:
...
...
@@ -440,7 +479,7 @@ Version: %s''' % __version__
break
# else keep trying next option
else
:
usage
(
msg
=
'Invalid option: '
+
arg
)
usage
(
1
,
msg
=
'Invalid option: '
+
arg
)
# now set the values
device
.
setinfo
(
info
)
device
.
close
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment