Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32061 > unrolled thread
| Started by | Muffinman <news**REMOVETHIS**@koster.tk> |
|---|---|
| First post | 2012-10-24 20:55 +0200 |
| Last post | 2012-10-24 22:59 -0700 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.python
Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x) Muffinman <news**REMOVETHIS**@koster.tk> - 2012-10-24 20:55 +0200
Re: Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-24 22:58 +0000
Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x) David Hutto <dwightdhutto@gmail.com> - 2012-10-24 21:35 -0400
Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x) David Hutto <dwightdhutto@gmail.com> - 2012-10-24 21:42 -0400
Re: Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x) Tim Roberts <timr@probo.com> - 2012-10-24 22:59 -0700
| From | Muffinman <news**REMOVETHIS**@koster.tk> |
|---|---|
| Date | 2012-10-24 20:55 +0200 |
| Subject | Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x) |
| Message-ID | <508839a7$0$785$58c7af7e@news.kabelfoon.nl> |
Hello all,
I'm new to Python (running 2.6.6 but if necessary 3.x should also be
fine). I have a little idea I hope to accomplish with Python. I want to
listen for changes in Alsa sound volume level and base some actions on
that. With the few lines below I can check the current volume level. Can
I extend this so that the script listens for changes in the volume level
and I can base some actions on it? As speed is quite important it's not
an option to poll every second or so for changes, it has to be close to
instantaneous.
If this is not possible with Python, any suggestions on what else are
also welcome of course.
Thanks in advance, Maarten
#############
try
mixer = alsaaudio.Mixer(Fake, 0)
except alsaaudio.ALSAAudioError:
sys.stderr.write("No such mixer\n")
sys.exit(1)
volumes = mixer.getvolume(1)
#############
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-10-24 22:58 +0000 |
| Message-ID | <508872a6$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #32061 |
On Wed, 24 Oct 2012 20:55:35 +0200, Muffinman wrote: > Hello all, > > I'm new to Python (running 2.6.6 but if necessary 3.x should also be > fine). I have a little idea I hope to accomplish with Python. I want to > listen for changes in Alsa sound volume level and base some actions on > that. With the few lines below I can check the current volume level. Can > I extend this so that the script listens for changes in the volume level > and I can base some actions on it? As speed is quite important it's not > an option to poll every second or so for changes, it has to be close to > instantaneous. Then poll every millisecond or so. I don't believe it is possible to listen for changes in an arbitrary variable. But if you check the alsaaudio module, or ask on a dedicated alsa mailing list, you may be able to find out how alsa records the volume in the first place. If it is written to a file, you can listen for changes to the file without polling on Linux systems. > If this is not possible with Python, any suggestions on what else are > also welcome of course. That's not a Python question, it's an Alsa question. Who knows how the sound volume is stored? -- Steven
[toc] | [prev] | [next] | [standalone]
| From | David Hutto <dwightdhutto@gmail.com> |
|---|---|
| Date | 2012-10-24 21:35 -0400 |
| Subject | Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x) |
| Message-ID | <mailman.2808.1351128940.27098.python-list@python.org> |
| In reply to | #32061 |
On Wed, Oct 24, 2012 at 2:55 PM, Muffinman <news**REMOVETHIS**@koster.tk> wrote:
> Hello all,
>
> I'm new to Python (running 2.6.6 but if necessary 3.x should also be
> fine). I have a little idea I hope to accomplish with Python. I want to
> listen for changes in Alsa sound volume level and base some actions on
> that.
With the few lines below I can check the current volume level. Can
> I extend this so that the script listens for changes in the volume level
> and I can base some actions on it? As speed is quite important it's not
> an option to poll every second or so for changes, it has to be close to
> instantaneous.
>
> If this is not possible with Python, any suggestions on what else are
> also welcome of course.
>
> Thanks in advance, Maarten
>
>
> #############
> try
> mixer = alsaaudio.Mixer(Fake, 0)
> except alsaaudio.ALSAAudioError:
> sys.stderr.write("No such mixer\n")
> sys.exit(1)
>
> volumes = mixer.getvolume(1)
> #############
> --
> http://mail.python.org/mailman/listinfo/python-list
first look at the docs for command line functions that utilize the
command line for access to certain CL apps.
Once you've found a way to access the CL apps with python(I use
subprocess.call usually, I think, but there's popen, etc.) then use
man alsamixer, or man aplayer, or man arecorder. in the shell on your
linux distro.
Then throw in a little tkinter, or a windowing system of your choice,
and distort the changes with command line calls.
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
[toc] | [prev] | [next] | [standalone]
| From | David Hutto <dwightdhutto@gmail.com> |
|---|---|
| Date | 2012-10-24 21:42 -0400 |
| Subject | Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x) |
| Message-ID | <mailman.2809.1351129376.27098.python-list@python.org> |
| In reply to | #32061 |
On Wed, Oct 24, 2012 at 2:55 PM, Muffinman <news**REMOVETHIS**@koster.tk> wrote: > Hello all, > > I'm new to Python (running 2.6.6 but if necessary 3.x should also be > fine). I have a little idea I hope to accomplish with Python. I want to > listen for changes in Alsa sound volume level and base some actions on > that. With the few lines below I can check the current volume level. Can > I extend this so that the script listens for changes in the volume level > and I can base some actions on it? As speed is quite important it's not > an option to poll every second or so for changes, it has to be close to > instantaneous. > You might have to go to c++(ctypes function call), like I'm going to have to for a oscilloscope(using arecord probably, or other options), and use in line assembly to push straight from/to the register. I haven't had a good look at python's IO module yet though. Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com
[toc] | [prev] | [next] | [standalone]
| From | Tim Roberts <timr@probo.com> |
|---|---|
| Date | 2012-10-24 22:59 -0700 |
| Message-ID | <d2lh885ik9bncrhct7isnq6epdm5k6it2f@4ax.com> |
| In reply to | #32061 |
Muffinman <news**REMOVETHIS**@koster.tk> wrote: > >I'm new to Python (running 2.6.6 but if necessary 3.x should also be >fine). I have a little idea I hope to accomplish with Python. I want to >listen for changes in Alsa sound volume level and base some actions on >that. With the few lines below I can check the current volume level. ... > >volumes = mixer.getvolume(1) Now, do you understand that this is just fetching the current setting of the volume control for the microphone? It's not telling you anything about the actual level of the sounds being captured. The fact that you're talking about real-time response makes me think you might be misunderstanding this. -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web