Timing and Metronome

sxSetTempo() sxGetTempo() sxGetTempoList()
sxSetRelativeTempo() sxGetTick() sxGetEternalTick()
sxSetMetronome() sxGetMetronome() sxSetCountIn()
sxGetCountIn() sxSetMetronomeVelocity() sxGetMetronomeVelcity()
sxSetmetronomeChannel() sxGetMetronomeChannel() sxSetMetronomeNote()
sxGetmetronomeNote() sxSetTimeSign() sxGetTimeSign()
sxGetTimeSignList()


In this section You find tools for working with the timing aspectts of MIDI. You can examine and control the tempo, time signature and position of Your Song, as well as control various aspects of the optional metronome.


sxSetTempo(mySong, tempo)
sxSetTempo sets the tempo in mySong. The tempo argument can be an integer or a linear lingo list. If tempo is an integer the first tempo value in the song will be set. If tempo is a list tempo will replace all tempo values in the whole song.

The list is built like this:
[[position1, tempo1], [position2, tempo2], [position3, tempo3]...]
The position element can be a list or an integer. If it is an integer sequenceXtra will interpret this as a tick.


Result code: Standard error code.

Example1:
on mouseUp
 global mySong
 sxSetTempo(mySong, 97) - Sets the songs first tempo value.
end moseUp

 

Example2:
on mouseUp
 global mySong
 set tempoList = [[0,100], [1920,120], [3840,200], [8000,40]]
 sxSetTempo(mySong, tempoList)
end mouseUp


 

sxGetTempo(mySong)
sxGetTempo returns the current tempo. This function is preferabely used when sequenceXtra is playing, as it returns the current tempo. To check a songs tempo while sequenceXtra is stopped, use sxGetTempoList() instead.

Result code:
Positive integer: Current tempo.
Negative integer: Standard error code.

Example:
on exitFrame global mySong put sxGetTempo(mySong) into field "tempo" end exitFrame


 

sxGetTempoList(mySong)
sxGetTempoList returns a linear list of time positions and their corresponding tempo values in the referred song.

Result code:
Negative integer: Standard error code
List: Linear list with the referred songs tempo values. The elements in the list contain a position in ticks and a tempo value.

Example:
on mouseUp
 global mySong
 put sxGetTempoList(mySong)
end mouseUp

Could return
[[0,120], [2840,165], [65000,200]]


 

sxSetRelativeTempo(mySong, tempoChange)
sxSetRelativeTempo changes the tempo values in the referred song with a factor that is indicated by the argument tempoChange. The argument can be an integer or a floating point value.

If tempoChange is an integer, sequenceXtra will interpret this as a percentage, and all tempo values in the song will be changed by that percentage. If tempoChange is a floating point value all tempo values will be multiplied with that value.


Result code: Standard error code

Example1:
on mouseUp 
 global mySong 
 sxSetRelativeTempo(mySong, 150) -- tempoChange as integer
end mouseUp

This will increase all tempo values by 50%

Example2:
on mouseUp
 global mySong
 sxSetRelativeTempo(mySong, 0.75) -- tempoChange as float
end mouseUp
This will multiply all tempo values with 0.75


 

sxGetTick(mySong)
sxGetTick returns the current position in Ticks.

Result code: Standard error code

Example:
on exitFrame
 global mySong
 put mySong.sxGetTick() into field "position"
end exitFrame

 

sxGetEternalTick()
sxGetEternalTick returns the current position in Ticks since sequenceXtra first was started with sxOpenSequencer. sxGetEternalTick does not take the song argument since it is not reffering to a song.

Result code: Standard error code

Example:
on exitFrame global elapsedTime elapsedTime = sxGetEternalTick() end exitFrame

 

sxGetPos(mySong{,format{,tick }})
sxGetPos converts a Tick value to a bar number, beat and/or subdivision. The function can be used in three ways.

Example 1:
on mouseUp
 global mySong 
 put sxGetPos(mySong)
end mouseUp

Could return [12, 0, 240]
Example 2:
on mouseUp global mySong put sxGetPos(mySong, #bar) end mouseUp
Could return 12

 

 

xSetMetronome(state)
sxSetMetronome sets the state of the metronome.

0: metronome off
1: metronome on while recording only
2: metronome on while recording and playback

Result code:
Positive integer: previous state of the metronome.
Negative integer: Standard error code

Example:
on mouseUp
 set newState = the hilite of member "Metronome switch"
 if newState then sxSetMetronome(2)
 else sxSetMetronome(1)
end mouseUp

 

sxGetMetronome()
sxGetMetronome returns the current metronome setting.

Result code:
Positive integer: current metronome setting
(0: off, 1:on while recording, 2: always on)
Negative integer: Standard error code

 

sxSetCountIn(bars)
sxSetCountIn sets the count in length in bars. bars must be a positive integer

Result code: Standard error code.

 

sxGetCountIn()
sxGetCountIn returns the count in lenght in bars

Result code:
Positive integer: count in lenght
Negative integer: Standard error code.

 

sxSetMetronomeVelocity(velo)
sxSetMetronomeVelocity sets the velocity of the metronome beats.

Result code: Standard error code.

Example:
on mouseUp
 sxSetMetronomeVelocity(100)
end mouseUp

 

sxGetMetronomeVelocity()
returns the velocity of the metronome beats

Example:
on mouseUp
 set metronomeVelo = sxGetMetronomeVelocity()
end mouseUp

 

sxSetMetronomeChan(channel)
sxSetMetronomeChan sets the MIDI channel of the metronome. Channel must be an integer between 1 and 16

Result code: Standard error code

Example:
on mouseUp
 sxSetMetronomeChan(10)
end mouseUp

 

sxGetMetronomeChan()
sxGetMetronomeChan returns the current metronome MIDI channel.

Result code:
Negaitve Integer: Standard error code
Positive integer: Metronome channel

Example:
on mouseUp
 set metronomeChan = sxGetMetronomeChan()
end mouseUp

 

sxSetMetronomeNote(noteNum)
sxSetMetronomeNote sets the note number for the metronome to noteNum

Result code: Standard error code

Example:
on mouseUp
 sxSetMetronomeNote(60)
end mouseUp

 

sxGetMetronomeNote()
sxGetMetronomeNote returns the current metronome note number

Result code:
Negative Integer: Standard error code
Positive Integer: Metronome nute number

Example:
on mouseUp
 set metronomeNote = sxGetMetronomeNote()
end mouseUp

 

sxSetTimeSign(mySong, {nominator, denominator} or {timeSignList})
sxSetTimeSign sets the time sign of the referred song. The function accepts two different types of argument: two integers or a linear list If the argument contains two integers, this will be interpreted as the songs first time sign. The first integer is the nominator and the second the denominator. If the argument is a list, time signs will be inserted according to the list:
[[timeStamp1, nominator, denominator],[timeStamp2, nominator, denominator]...]

Result code: Standard error code.

Example 1 (two integers):
on mouseUp
 global mySong
 sxSetTimeSign(mySong, 3, 4)
end mouseUp
             
Example 2 (a list):
on mouseUp
 global mySong 
 sxSetTimeSign(mySong, [[1,4,4], [3,3,4]])
end mouseUp

 

sxGetTimeSign(mySong)
sxGetTimeSign returns the current timeSign for the referred song. The time signature is returned as a linear list with two values: [nominator, denominator].

Result code:
A list: the current time signature of the referred song
Negative integer: Standard error code

Example:
on mouseUp
 global mySong
 put sxGetTimeSign(mySong)
end mouseUp

Could return: [4, 4]


 

sxGetTimeSignList(mySong)
sxGetTimeSignList returns a linear list of the time signatures in the referred song.
Each entry in the list is a list itself with three values [timestamp, nominator, denominator]

Example:
on mouseUp
 global mySong
 put sxGetTimeSignList(mySong)
end mouseUp

Could return: [[0, 4, 4], [1920, 3, 4]]