itunes auto cross fade setup

Need help? Ask your questions here! I'll try to answer every one, but anyone can answer!
olskoolpro
Posts: 9
Joined: Tue Dec 14, 2010 9:48 am
Location: San Jose, CA
Contact:

itunes auto cross fade setup

Post by olskoolpro »

Greetings - I am a new Mac user and a New KJams Pro user and I would love to utilize the Auto Cross Fade for iTunes.

I have read the Q&A on this subject, however my knowledge of MAC is still so limited, it would be very helpful if there was a tutorial on where to paste the script for this auto cross fade. Can you please walk me through the steps to set up the auto cross fade? I would greatly appreciate it.

Thanks

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: itunes auto cross fade setup

Post by DeusExMachina »

Hi:
I am one of the people who wrote the code, and Dave sent me here to answer your question.
In order to use the script, the easiest way to do it is to open Applescript Editor (came with your mac) and paste the code into a new script window. Then save as an application, and run as you would any other application. It should then be in the scripts menu in the menubar. If you do not have a scripts menu, simply open preferences in AppleScript Editor, and check "Show Script menu in menu bar" under the General tab.
Alternately, you can save it as a service. Open up Automator, select "Service" from the template choices on the opening splash screen, and then drag "Run AppleScript" from the Library onto the Stage. Change the "Service receives selected" popup to "no input", and "applications" to "kJams". (First choose "other…" from the popup menu, and then browse to kJams in the file selector.) Next, paste the code over top of where is says "(* Your script goes here *)" and save. Now the script will be in the "Services" menu under the kJams menu.

And welcome to OSX!
Last edited by DeusExMachina on Tue Dec 14, 2010 1:16 pm, edited 1 time in total.

dave
Site Admin
Posts: 6684
Joined: Sun Sep 18, 2005 8:02 am
Location: Seattle
Contact:

Re: itunes auto cross fade setup

Post by dave »

wow!
what he said!
:shock:

olskoolpro
Posts: 9
Joined: Tue Dec 14, 2010 9:48 am
Location: San Jose, CA
Contact:

Re: itunes auto cross fade setup

Post by olskoolpro »

Hi All, I installed the script for the auto cross fade, and as soon as i hit run itunes begins to play - then When kjams begins to play ITunes isn't fading out. Can you help?

Thanks

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: itunes auto cross fade setup

Post by DeusExMachina »

OK, I think there is a bit of confusion going on here. I have two scripts up. The one automates the cross fade between iTunes and kJams on a single time basis. You have to run it each time you want to crossfade. This is the one I use (actually, I don't really use either of them, I just wrote them to torture myself, since I hate writing code, and SUCK at it!)
The other one automates the process completely, and runs in the background. You run it once, and it senses what you are doing in kJams, and fires up iTunes when you are not playing a track in kJams.

I think you are running the former, but expecting the behaviour of the latter. If so, what you want is this:
http://karaoke.kjams.com/wiki/Code/new_ ... Crossfader

olskoolpro
Posts: 9
Joined: Tue Dec 14, 2010 9:48 am
Location: San Jose, CA
Contact:

Re: itunes auto cross fade setup

Post by olskoolpro »

Perfect This is what i was looking for. Thank you again. You made me work a whole lot easier. :D

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: itunes auto cross fade setup

Post by DeusExMachina »

Cheers.

simpmech
Posts: 116
Joined: Thu Mar 24, 2011 5:05 pm

Re: itunes auto cross fade setup

Post by simpmech »

Just wanted to say NICE! This works great, thank you!

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: itunes auto cross fade setup

Post by DeusExMachina »

YVW.

Feel free to check out some of the other code here:
http://karaoke.kjams.com/wiki/Code

vialli25
Posts: 11
Joined: Sun Oct 30, 2011 4:00 am

Re: itunes auto cross fade setup

Post by vialli25 »

Hi

Nothing urgent, but would it be possible to start the iTunes fade in before the karaoke track has finished?

For example, there is about 10 seconds of silence at the end of most karaoke tracks where it displays the name and publisher information. Would be great if you could fade iTunes music in over this.

Cheers

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: itunes auto cross fade setup

Post by DeusExMachina »

Sure it would be possible. My first question, though, is which of the three iTunes crossfaders are you talking about. I wrote or modified two of them, and there is a third one floating around written in BASH I think. I can only really do anything with the ones I wrote in AppleScript. Alternately, you could just open the script in ApplesScript and edit it yourself. I commented it pretty thoroughly, so even if you don't know AppleScript, you should be able to find the part to change and how to change it.

dave
Site Admin
Posts: 6684
Joined: Sun Sep 18, 2005 8:02 am
Location: Seattle
Contact:

Re: itunes auto cross fade setup

Post by dave »

8)

vialli25
Posts: 11
Joined: Sun Oct 30, 2011 4:00 am

Re: itunes auto cross fade setup

Post by vialli25 »

I'm talking about the Applescript AUTOMAGICAL crossfader that you linked to above.

Before I say anything else though, I would just like to congratulate both you and dave on an outstanding plugin and piece of software respectively. My Dad and I used it at a gig last night and it is just amazing how simple the software is to use, but I also get excited when I think of the possibilities as well, as it is obviously continuously improving upon user feedback.

Now, back to the script. I did have a brief look in there but didn't see anything about the timing of when the fade starts to happen. I assumed you would have just told it to fade at the end of the track, and I'm so inexperienced with Applescript I wouldn't know how to add in a line to tell it to fade in 5 second before the end for example.

I would love to learn Applescript, so if you give me a few pointers I'm sure I could try and figure it out myself.

Thanks

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: itunes auto cross fade setup

Post by DeusExMachina »

Going back over this thread, it seems to me that what you really want is not the autoCrossFader, since you can never really guarantee when the track will actually end, but rather the simple CrossFader. This one you just call when you want the cross fade to begin.
Is is available in the code section, or right here:
-- Please have iTunes and kJams running before launching this script and
-- have a playlist selected in iTunes
-- The simple logic of the script assumes that if iTunes is playing and this script is run,
-- you want to cross fade over to kJams.. Alternately, if iTunes is not playing a track,
-- it assumes you want to cross fade over to iTunes.
-- when you are ready to cross fade to kJams, make sure your next song is
-- highlighted/selected. It will NOT automatically go to the next track in
-- your kJams playlist.
-- Unlike the original version of this script, you do not need to set your max volume levels. Instead, it will poll iTunes and kJams for their current volumes, and then cross fade using those values. Even if these volumes are very different, it will fade them such that they reach their appropriate values at the same time. No more need for these values to be identical!
-- Although I have tested this code, I make no guarantees with this code,
-- any disasters that occur are not my fault. Use at your own risk!!
tell application "iTunes"

set kSpeakers to 0
--sets how long in seconds between each step in the fade
set fadeDelay to 0.1
set kScriptCommand_PLAY_PAUSE to 1
set kScriptCommand_STOP to 2
--Get current audio volume from kJams
tell application "kJams Pro" to set kJamsMaxVolume to get volume kSpeakers
--set iTune volume maximum.
set iTunesMaxVolume to the sound volume
-- Number of steps in fade
set fadeSteps to 20
--sets how much in percentage the volume is decreased per step
set kJFadeStep to kJamsMaxVolume / fadeSteps
set iTFadeStep to iTunesMaxVolume / fadeSteps
--this is the minimum volume setting
set MinVolume to 0

if (player state is playing) then
--set all volumes to cross fade starting values
set kJamsVolume to MinVolume
set iTunesVolume to iTunesMaxVolume
tell application "kJams Pro"
set volume kSpeakers level MinVolume
docommand kScriptCommand_PLAY_PAUSE
end tell
repeat until (iTunesVolume ≤ 0 and kJamsVolume ≥ kJamsMaxVolume)
set iTunesVolume to (iTunesVolume - iTFadeStep)
set kJamsVolume to (kJamsVolume + kJFadeStep)
set the sound volume to iTunesVolume
tell application "kJams Pro" to set volume kSpeakers level kJamsVolume
delay fadeDelay
end repeat

pause
set the sound volume to iTunesMaxVolume

else
--set all volumes to cross fade starting values
set iTunesVolume to MinVolume
set kJamsVolume to kJamsMaxVolume
tell application "kJams Pro" to set volume kSpeakers level kJamsMaxVolume
set the sound volume to MinVolume
play
repeat until (kJamsVolume ≤ 0 and iTunesVolume ≥ iTunesMaxVolume)
set iTunesVolume to (iTunesVolume + iTFadeStep)
set kJamsVolume to (kJamsVolume - kJFadeStep)
tell application "iTunes" to set the sound volume to iTunesVolume
tell application "kJams Pro" to set volume kSpeakers level kJamsVolume
delay fadeDelay
end repeat
tell application "kJams Pro"
docommand kScriptCommand_STOP
set volume kSpeakers level kJamsMaxVolume
end tell
end if
end tell

You COULD modify the autoCrossFader to do what you want, but you'd have to change some control logic. Here, instead of sensing when kJams is not playing, it would have to read in the duration of the currently playing track, subtract say fifteen seconds from that, set up a timer, and then fire the crossfader at that time. it would be some work, but I don't think it really is useful, since again, you can not tell when that is going to be, and it is easier just to fire the crossFader script manually.

vialli25
Posts: 11
Joined: Sun Oct 30, 2011 4:00 am

Re: itunes auto cross fade setup

Post by vialli25 »

Thanks for the suggestion.

I'll give it a go but think I'll just stick with the automatic one. There is something satisfying about just pressing the spacebar to make it all happen. As I said it's no biggie.

Cheers

Post Reply