From kJams Wiki
Jump to: navigation, search

Note that kJams 2 uses Python scripting!

You can use AppleScript to cause kJams Pro to export your songs to QuickTime format.

Here is an example script for kJams:

tell application "kJams Pro"
	-- returns the version of kJams that is running
	-- a test property, returns false if kJams is not crashed.  set this to true to make kJams crash
	--set crash to true
	-- it is okay to add the same song twice from a script, it will only be added once
	-- it is also okay if the song is on a CD, it won't actually add to the library in that case
	-- must pass a POSIX path
	set songID to add to library "/Volumes/SGB0001 - Free Style Jazz Volume 1/7 The Lady Is A Tramp.aiff"
	if songID is not 0 then
		-- POSIX path for output folder, tilde is okay for user folder
		export songID encoder "QuickTime Movie" preset "Animation / AAC Best" folder "~/Desktop"
	end if

	-- get or set the volume of mics and speakers.  volume level goes from 0 to 100
	set kSpeakers to 0
	set kMicrophone_1 to 1
	set volume kSpeakers level 50
	get volume kMicrophone_1

	-- you can get the current time, the remaining time, or the absolute duration of the currently playing song.
	-- curT is in floating point seconds
	set kCurSongTime_DURATION to 0
	set kCurSongTime_CURRENT to 1
	set kCurSongTime_REMAINING to 2

	set curT to get time kCurSongTime_CURRENT

	-- you can get the current mode too (stopped, playing, paused)
	set kPlayModeType_STOPPED to 0
	set kPlayModeType_PLAYING to 1
	set kPlayModeType_PAUSED to 2

	set playMode to get mode
end tell

Hey! Here's the first application using scripting! The Crossfade Script!

or try this

Simple commands if you want to write your own Remote Control software:

set kScriptCommand_PLAY_PAUSE to 1
set kScriptCommand_STOP to 2
set kScriptCommand_BACK_REWIND to 3
set kScriptCommand_NEXT to 4
set kScriptCommand_VOL_UP to 5
set kScriptCommand_VOL_DOWN to 6
set kScriptCommand_VOL_MUTE to 7
set kScriptCommand_PITCH_UP to 8
set kScriptCommand_PITCH_DOWN to 9
set kScriptCommand_PITCH_NORMAL to 10
set kScriptCommand_SAVE to 11
set kScriptCommand_TEMPO_UP to 12
set kScriptCommand_TEMPO_DOWN to 13
set kScriptCommand_TEMPO_NORMAL to 14
set kScriptCommand_FULL_SCREEN to 15
set kScriptCommand_CAM_POWER to 16
set kScriptCommand_CAM_SHOOT to 17
set kScriptCommand_CRASH to 18
set kScriptCommand_RESCAN_VENUE to 19
set kScriptCommand_SHOW_ROTATION to 20
set kScriptCommand_HIDE_SHOWSCREEN to 21
set kScriptCommand_IS_SHOWSCREEN_SHOWING to 22
set kScriptCommand_GET_SHOW_ROTATION_TIME_REMAIN to 23
set kScriptCommand_TOGGLE_TRANSPARENT_VIDEO to 24
set kScriptCommand_IS_TRANSPARENT_VIDEO to 25
set kScriptCommand_GET_VIDEO_WINDOW_DISPLAY_ID to 26
set kScriptCommand_GET_IND_SONG_ID to 27
set kScriptCommand_GET_PLAY_MODE to 47
set kScriptCommand_Get_ModDate to 63

The ones with "Str" in them return strings, the rest return a floating point number

set kScriptCommandStr_GetAppVersion to 40

set kScriptCommandStr_GetCurSongName to 41
set kScriptCommandStr_GetCurSongPath to 42
set kScriptCommandStr_GetCurSongCachePath to 43

set kScriptCommandStr_GetNextSongName to 44
set kScriptCommandStr_GetNextSongPath to 45
set kScriptCommandStr_GetNextSongCachePath to 46
tell application "kJams Pro"
	docommand kScriptCommand_PLAY_PAUSE
	set is_showingB to docommand kScriptCommand_IS_SHOWSCREEN_SHOWING
	if is_showingB
		// do something
	end if

	set myString to docommand_str kScriptCommandStr_GetCurSongPath
	// do something with the path.  check for empty path first!
end tell