Welcome to Форум на приятелите на Apple. Please login or sign up.

15-05-2024, 08:02:56

Login with username, password and session length

Shoutbox


Recent

Потребители
  • Общ брой потребители: 7 861
  • Latest: kaldoor
Stats
  • Общ брой публикации: 82 652
  • Общ брой теми: 9 810
  • Online today: 598
  • Online ever: 774
  • (Вчера в 04:09:55)
Онлайн потребители
Users: 2
Guests: 548
Total: 550

548 гости, 2 потребители
veskop, Steve

Crossfader

Започната от dreben, 23-11-2011, 16:18:07

« назад - напред »

0 Потребители и 1 гост преглеждат тази тема.

dreben

Здравейте,
Понякога имам участия и се изявявам като KJ(Караоке водещ). Ползвам програмката "Kjams", която ми дава възможност да ползвам "Itunes" между съответните файлове. Има написан скрипт, който активира "Crosfader", след спирането на дадена песен с плавно затихване и започване в двете посоки. Тайно се надявам да съм бил ясен в описанието.
Понякога обаче ми се налага и да бъда като DJ(неприятно но...) с "MegaSeg" и обратно KJ - "Kjams".
Въпросът ми е може ли да се напише подобен скрипт, чрез който плавно да преминавам от едната програма към другата. По долу е скрипта който ползвам.
-- 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!!

set kSpeakers to 0
--sets how long in seconds between each step in the fade
set fadeDelay to 0.1

--established kJams command codes
set kScriptCommand_PLAY_PAUSE to 1
set kScriptCommand_STOP to 2

--set all volumes to cross fade starting values
--Get current audio volume from kJams
tell application "kJams Pro" to set kJamsMaxVolume to get volume kSpeakers
--get iTune volume maximum.
tell application "iTunes" to 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

-- Playstate will be either 1 for iTunes or 0 for kJams
set playState to 0
set prevPlayState to 0

--sets kJams state variable codes
set kPlayModeType_STOPPED to 0
set kPlayModeType_PLAYING to 1
set kPlayModeType_PAUSED to 2

repeat
   --is kJams playing?
   tell application "kJams Pro"
      set playMode to get mode
   end tell
   tell application "iTunes"
      -- Check to see if kJams is playing
      if (playMode = kPlayModeType_PLAYING) then
         -- if so, set current playstate to playing
         set playState to 0
         -- If prevPlayState is not the same as the current state
         --i.e. if kJams is has just started playing, fade in kJams and fade out iTunes
         if (prevPlayState = 1) then
            tell application "kJams Pro" to set currentVolume to get volume kSpeakers
            if currentVolume ≠ MinVolume then set kJamsMaxVolume to currentVolume
            --sets how much in percentage the volume is decreased per step
            set kJFadeStep to kJamsMaxVolume / fadeSteps
            set kJamsVolume to MinVolume
            -- get current starting volume from iTunes
            set iTunesVolume to the sound volume
            tell application "kJams Pro" to set volume kSpeakers level MinVolume
            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
            -- if you want iTunes to pick up where it left off, remove the following line
            next track
            pause
         end if
      else
         -- if kJams is not playing, set current playstate to "not playing"
         set playState to 1
         --if kJams has just now been paused, cross fade in iTunes
         if (prevPlayState = 0) then
            set currentVolume to the sound volume
            if currentVolume ≠ MinVolume then set iTunesMaxVolume to currentVolume
            set iTFadeStep to iTunesMaxVolume / fadeSteps
            --Get current audio volume from kJams
            tell application "kJams Pro" to set kJamsMaxVolume to get volume kSpeakers
            set kJFadeStep to kJamsMaxVolume / fadeSteps
            tell application "kJams Pro" to set volume kSpeakers level MinVolume
            --set all volumes to cross fade starting values
            set iTunesVolume to MinVolume
            set the sound volume to MinVolume
            play
            repeat until iTunesVolume ≥ iTunesMaxVolume
               set iTunesVolume to (iTunesVolume + iTFadeStep)
               set the sound volume to iTunesVolume
               --tell application "kJams Pro" to set volume kSpeakers level MinVolume
               delay fadeDelay
            end repeat
         end if
         --Get current audio volume from iTunes
         set iTunesMaxVolume to the sound volume
         set iTFadeStep to iTunesMaxVolume / fadeSteps
         
      end if
      set prevPlayState to playState
      delay 0.5
   end tell
end repeat
Macbook Pro-4.1 Early 2008-Mat
Macbook Pro 14" M1Pro 2021
Imac 18,3 - 27" Retina 5K 2017