OrderedBytes User Forum
Home News ControllerMate Support Forum Home
FAQ FAQ     Search Search     Memberlist Memberlist     Usergroups Usergroups     Register Register
Profile Profile     Log in to check your private messages Log in to check your private messages     Log in Log in
Controlling iTunes volume with a scroll wheel
Display posts from previous:         View previous topic :: View next topic
Post new topic Reply to topic Subscribe to this topic    The OrderedBytes Forum -> ControllerMate Discussion
Sun Mar 29, 2009 12:01 pm  •   #4087
xltrader100



Joined: 16 Dec 2008
Posts: 96

Quote:
In some cases, I can setup ControllerMate to "see" a device's Fn key. This allows a user to create programming that responds to the Fn key. For example, I use Fn-F14 and Fn-F15 to control iTunes' volume...

Ken, are you saying that CMate can control iTunes up/dn volume? And if so, is there any way that this could be controlled by the scroll wheel (maybe with a modifier) instead of by buttons or keys?
View user's profile Send private message Reply with quote
Sun Mar 29, 2009 6:00 pm  •   #4090
Ken
Developer


Joined: 27 Mar 2006
Posts: 2094

I use the following AppleScripts to control iTunes' volume.

Mute:
Code:
tell application "iTunes"
   if ( mute )
      set mute to false
   else
      set mute to true
   end if
end tell


Volume Down:
Code:
tell application "iTunes"
   set current_volume to sound volume
   set sound volume to ( current_volume - 4 )
end tell


Volume Up:
Code:
tell application "iTunes"
   set current_volume to sound volume
   set sound volume to ( current_volume + 4 )
end tell


These can probably be tightened up, but I tend to be verbose. To use them with a scroll wheel, you could do something similar to this post using AppleScript blocks instead of the Single Key blocks.
_________________
Ken
www.orderedbytes.com - www.controllermate.com
ControllerMate -- Programming controllers for Mac OS X since ... well ... recently.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Sun Mar 29, 2009 7:28 pm  •   #4091
xltrader100



Joined: 16 Dec 2008
Posts: 96

Thanks, that worked great. But I'm running into trouble when I try to disable the normal scroll wheel function during the time I'm using it to control iTunes. I have the real mouse scroll disabled, and the virtual mouse scroll enabled, but the real mouse is still connected to the virtual mouse. How do I disconnect them so I can put something like a number gate in between them?
View user's profile Send private message Reply with quote
Sun Mar 29, 2009 8:38 pm  •   #4092
Ken
Developer


Joined: 27 Mar 2006
Posts: 2094

xltrader100 wrote:
...during the time I'm using it to control iTunes


I'm guessing that you want the scroll wheel to act like a scroll wheel sometimes, and to control iTunes volume at other times. How is the distinction made? When iTunes is in the foreground? When holding another button or key?
_________________
Ken
www.orderedbytes.com - www.controllermate.com
ControllerMate -- Programming controllers for Mac OS X since ... well ... recently.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Mon Mar 30, 2009 2:45 am  •   #4098
xltrader100



Joined: 16 Dec 2008
Posts: 96

Jay, my apologies for hijacking your thread.

Here's what I wound up with.
http://gallery.me.com/xltrader100#gallery

This config uses a middle click to enable the firing of a burst of Applescripts (at 10 scripts /sec) to send iTunes volume up/down. After the middle click, only a single movement of the wheel is needed to start the iTunes volume slider moving smoothly in one direction or the other, and then when the volume reaches the desired level a second middle click stops the action. By that time the 3 second delay has timed out and everything goes back to normal.

So it's that 3 second period after the first middle click and during which time I'm going to be moving the scroll wheel that I'd like to disable its default action. Right now, when I move the scroll wheel to set the volume, it also scrolls the window. Which doesn't sound like the end of the world, but with this free scrolling wheel I've got into the habit of kind of flicking the wheel instead of pushing it, and that produces dramatic results on a long document.

The blocks with the number gate are what's not working at the moment because the virtual mouse appears to stay connected to the real mouse even if that number gate disappears.

btw, this config has a couple of gotchas that will limit it's general usefulness.
1) It only works with a Logitech mouse that has the free running scroll wheel. As soon as I engage the detent action then this config quits working, which is still ok for my needs because free scrolling is all I ever use.

2) The initiating button (I used middle click) for this action doesn't have to be totally dedicated to iTunes and can be shared with something else, but that something else has to be benign. For instance it would be fine to make "Copy" the normal middle click function while still using middle click to initiate iTunes volume change, but "Paste" wouldn't work.
View user's profile Send private message Reply with quote
Mon Mar 30, 2009 9:10 pm  •   #4105
Ken
Developer


Joined: 27 Mar 2006
Posts: 2094

How about something like this...


In this setup, I used Button #4 to turn on the "Adjust iTunes" modifier for 3.0 seconds. The two Wheel building blocks both depend on one value of the modifier. When "Adjust iTunes" is OFF, the Wheel building block that is attached to the Virtual Wheel building block is active. When the "Adjust iTunes" is ON, the bottom Wheel building block is active. The two scripts are driven in the same manner as in your setup.

The only non-obvious setting is that the behavior of the Wheel building blocks should be configured to set their output to "0" when their modifier values are incorrect. If that is omitted then the Wheel building blocks could get "stuck" with the wrong value when the "Adjust iTunes" modifier changes value.

P.S. I like the "legal pad" look.
_________________
Ken
www.orderedbytes.com - www.controllermate.com
ControllerMate -- Programming controllers for Mac OS X since ... well ... recently.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Tue Mar 31, 2009 12:34 pm  •   #4107
xltrader100



Joined: 16 Dec 2008
Posts: 96

Excellent! And your version works even when the wheel detente mechanism is engaged, which caused my version to quit. It takes a few tries to get used to this but after that it's quite a satisfactory volume control.


Edit:
I updated the picture to show how the iTunes addition fits in with the rest of the G9 config. http://gallery.me.com/xltrader100#gallery
View user's profile Send private message Reply with quote
Thu Apr 02, 2009 2:38 pm  •   #4113
xltrader100



Joined: 16 Dec 2008
Posts: 96

This iTunes volume control is a keeper, and now I want to extend it a bit so it also controls System volume.

As it works now, when the iTunes slider gets to the top of it's range but the volume still isn't loud enough then I have to reach for the System volume button to tweak it louder, and this is such a nasty an onerous job that it just cries out to be CMated out of existence. So, how can I detect when the iTunes slider hits the top of it's range so I can switch off the iTunes scripts and start firing the System volume scripts for the remainder of the 3 second window?
View user's profile Send private message Reply with quote
Thu Apr 02, 2009 11:47 pm  •   #4115
Ken
Developer


Joined: 27 Mar 2006
Posts: 2094

Fear not. Replace the AppleScript blocks with these:


Volume Down:
Code:
 tell application "iTunes"
   set volume_changed to 0
   if (sound volume > 0) then
      set sound volume to sound volume - 4
      set volume_changed to 1
   end if
   return volume_changed
end tell


Volume Up:
Code:
tell application "iTunes"
   set volume_changed to 0
   if (sound volume < 100) then
      set sound volume to sound volume + 4
      set volume_changed to 1
   end if
   return volume_changed
end tell


The AppleScript blocks return "1" if the script changed the iTunes volume. If it doesn't then the script returns "0" and the Pulse building block triggers the system volume change.
_________________
Ken
www.orderedbytes.com - www.controllermate.com
ControllerMate -- Programming controllers for Mac OS X since ... well ... recently.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Fri Apr 03, 2009 9:55 am  •   #4118
xltrader100



Joined: 16 Dec 2008
Posts: 96

Looking good, Ken. There were a couple of tweaks needed, mainly to do with the timing:
There are 16 (big) steps in the System volume control and 25 steps in the iTunes Applescripts, and there was a noticeable jump in the volume as it made the transition from one to the other, so to make the step sizes the same I increased the Applescript step constant from 4 to 6 and slowed down the auto-repeater a bit.

Then when it shifts gears and starts adjusting the System volume, I don't really want it to run all the way up or down its range, even if it has enough of the 3 second window left to do so because that would rarely be what's wanted, and much more often I'd want to just make small adjustments in the System volume. So I put in a counter that limits the System adjustment to just 3 steps in either direction for each attempt at a volume change. I set the Sound Pref to play feedback when the System volume is changed so if I hear that sound then I know iTunes is at the end of its range. http://gallery.me.com/xltrader100#gallery

All of the above is working very well. Now, one more thing from the "is he never satisfied" dept. When the iTunes slider gets down to one notch from the bottom end, then the next step means silence which is probably not what's wanted. So would it be possible to detect when the iTunes slider is below say 10, and use that as the switch-over point instead of zero?


Edit:
Fixed. Can't believe it was as simple as that. I really should learn more Applescript.
View user's profile Send private message Reply with quote
Tue May 19, 2009 10:27 pm  •   #4233
Basscadet



Joined: 19 May 2009
Posts: 1

I'm looking for a way to control itunes volume and also seek back and forth using to mouse wheel, placing the cursor anywhere on an itunes window, and/or when itunes is the front/main window being used.

This is to use mainly in full screen mode while watching video... I want to do like in VLC, scroll up/down= vol, and scroll left/right to seek. I love this function in VLC and would love to know if a solution exists for something like this in itunes, cuz itunes seems to me to be the best for organizing all media into one place, and all the artwork/cover flow is the smartest and coolest way to browse your collection.

I don't know scripting yet, so most of the posts don't make much sense to me, only I can tell that some of you guys are doing scripts that are very close to what I'm looking to do, a little help would be greatly appreciated.... Have mercy on the noob.... Thanks!


Last edited by Basscadet on Tue May 19, 2009 10:41 pm; edited 1 time in total
View user's profile Send private message Reply with quote
Tue May 19, 2009 10:38 pm  •   #4234
Ken
Developer


Joined: 27 Mar 2006
Posts: 2094

Basscadet wrote:
I'm looking for a way to control itunes volume and also seek back and forth using to mouse wheel, placing the cursor anywhere on an itunes window, when itunes is the front/main window being used. This is to use mainly in full screen mode while watching video... I want to do like in VLC, scroll up/down= vol, and scroll left/right to seek. I love this function in VLC and would love to know if a solution exists for something like this in itunes, cuz itunes is so good for organizing all media into one place. Thanks

There isn't a way for ControllerMate itself to know what window the cursor is currently over. If there is a way to do that in AppleScript, then the scripts would need to be modified to take that criterion into account.
_________________
Ken
www.orderedbytes.com - www.controllermate.com
ControllerMate -- Programming controllers for Mac OS X since ... well ... recently.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Sun Jun 07, 2009 2:38 pm  •   #4287
xltrader100



Joined: 16 Dec 2008
Posts: 96

Here's what I wound up with in my quest for a better volume control, and it works well. There are two main actions:
1) A quick press and release of the Modifier button (I used the Rear Thumb button, but any other could be used) will cause the Scroll Wheel to control iTunes volume Up/Dn for the next 1.5 seconds while normal page scrolling is disabled.
2) Press and Hold the Rear Thumb button, and the Scroll Wheel will control System Volume instead of iTunes volume, with no time-out.

The Scroll wheel control of System volume continues working exactly the same in XP under Fusion as it works on the Mac (just don't connect the mouse to the vm), but (although I haven't tried it) I wouldn't expect the Windows version of iTunes to respond to the Scroll Wheel.

This setup enhances the VLC scroll/volume function, which only controls between zero and the current value of System volume. Using this CMate action, when the VLC volume bar gets to the top but the volume still isn't loud enough, just press the Rear Thumb button and continue scrolling in the same direction to increase the System volume and give the VLC volume bar a wider range. This works for Windows VLC as well as Mac VLC.



This is what your virtual mouse should look like if you're only using it for this one action.



To try this out, download this CMate config file and double click it. Follow the on screen directions. http://files.me.com/xltrader100/17v31l
The only thing you'll have to add is your own virtual mouse, plus of course if you're not using a G9 mouse then you'll have to adapt your own button setup.
View user's profile Send private message Reply with quote
Page 1 of 1 All times are GMT - 6 Hours
Post new topic Reply to topic Subscribe to this topic    The OrderedBytes Forum -> ControllerMate Discussion
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Copyright © 2005 — 2010 OrderedBytes
All rights reserved.