|
| 1 | +# Dynamic Jams(DJ) system |
| 2 | + |
| 3 | +This module creates a middle ground between direct FRED event managed music and FSO's dynamic music system. DJ SEXPs allows for aligning mission event and musical transitions to the beat, and with the right music files this enables FREDers to get the cinematic effect that timing a mission to a static track can create without the mission rigidity or creation tedium that would normally entail. |
| 4 | + |
| 5 | +# Configuration |
| 6 | + |
| 7 | +Configuration files must be named `dj-*.cfg` and placed in data/configs. They are formatted with [fennel table syntax](https://fennel-lang.org/tutorial#tables), with example files included to pattern off of. |
| 8 | + |
| 9 | +# Transitions |
| 10 | + |
| 11 | +Transitions control how the system switches from one track to another. They have three components. |
| 12 | + |
| 13 | +## Alignment |
| 14 | + |
| 15 | +Alignment, `:align`, defines the point in time the rest of the transition will be relative to. |
| 16 | + |
| 17 | +Possible values: |
| 18 | +* `:instant` plays immediately |
| 19 | +* `:beat` aligns to the next beat of the currently playing track |
| 20 | +* `:measure` aligns to the next completed measure of the currently playing track |
| 21 | +* `:end` aligns to the end, or the next loop, of the currently playing track. |
| 22 | +* `:end_minus_beat` as the name implies, one beat before the end of the current track. Useful for crossfading in some cases. |
| 23 | +* `:end_minus_measure` as above, but one measure instead of one beat |
| 24 | + * Any other value is treated as instant. |
| 25 | + |
| 26 | +## Fade |
| 27 | +Fade definition allows you to define a crossfade between two tracks. Volume is managed with the assumption that one is fading in at the same time as the other is fading out, but you can define both periods seperately if you want. |
| 28 | + |
| 29 | +Each value of the fade is defined as `[:unit value]`. Valid units are, `:beat`, `:measure`, `:sec`, or `:full` for the full duration of the track. These are relative to the currently playing track.All fade values are relative to the alignment point, so `[:measure -0.5]` is one half measure before the alignment. |
| 30 | + |
| 31 | +Definable values: |
| 32 | +* `:newstart` When to start playing the new track. Negative values do allow starting the track earlier than the alighment point. Defaults to 0s. |
| 33 | +* `:endold` When to stop playing the old track. Defaults to 0s. |
| 34 | +* `:newfade` optional time to start fading out the old track. Defaults to equal `newstart` |
| 35 | +* `:oldfade` optional time to finish fading in the new track. Defaults to equal `endold` |
| 36 | + |
| 37 | +Fade definition is optional. |
| 38 | + |
| 39 | +## Margin |
| 40 | +`:margin` lets you set a minimum time that must pass before the anchor point, and is defined the same way as the fade periods. If the anchor point would fall inside the margin it is moved forward to the next valid anchor point. |
| 41 | + |
| 42 | +## Examples |
| 43 | + |
| 44 | +A slow fade over two measures, activated instantly. Useful for fading in from silence to music. |
| 45 | +```lisp |
| 46 | +:LongFadeI {:align :instant :newstart [:measure 0] :oldend [:measure 2]} |
| 47 | +``` |
| 48 | + |
| 49 | +A similar fade anchored to measures, useful for instance for fading out from music to silence |
| 50 | +```lisp |
| 51 | +:LongFadeM {:align :measure :newstart [:measure 0] :oldend [:measure 2]} |
| 52 | +``` |
| 53 | + |
| 54 | +A crossfade straddling a beat-long transition at a measure. This makes for a slightly noticable dip in the existing loop before the new track kicks in, which may or may not be desirable. The margin setting ensures at least 6 seconds pass before the transition, regardless of the measure length. |
| 55 | +```lisp |
| 56 | +:ExitLoop6s {:align :measure :newstart [:beat 0] :oldend [:beat 0.5] :newfade [:beat -0.5] :oldfade [:beat 0.5] :margin [:sec 6]} |
| 57 | +``` |
| 58 | +# Tracks |
| 59 | + |
| 60 | +A track is defined with the following properties. All must be present for a valid track. |
| 61 | + |
| 62 | +* `:file` The filename with extension for the actual music file. |
| 63 | +* `:bpmeasure` Beats per measure, the length of a measure in beats. |
| 64 | +* `:bpminute` Beats per minute, the tempo of the music. |
| 65 | +* `:dur` Duration, the length of the music in seconds |
| 66 | +* `:type` Set as `:loop` if the track is looping, any other value for non-looping tracks. |
| 67 | + |
| 68 | +## Examples |
| 69 | + |
| 70 | +A piece of music that is 10s of silence. You may need multiple of these with different beat and measure settings if you want to crossfade into music with different timings. |
| 71 | +```lisp |
| 72 | +:10s {:file :silent10s.ogg :bpmeasure 4 :bpminute 96 :duration 10 :type :loop} |
| 73 | +``` |
| 74 | + |
| 75 | +# Usage |
| 76 | +Sexps have in-fred docmentation for details, but the following is an overall of the tools and what they were created to do. |
| 77 | + |
| 78 | +## SEXP: (dj-queue "trackname" "transitionname") |
| 79 | + |
| 80 | +This sexp tells the system you want to play a named track, using a named transition. Names are case sensitive. If no track is already playing then the new track will always start immediately. |
| 81 | + |
| 82 | +If a track is already queued when you queue a new track, the previous queued track will be forgotten. |
| 83 | + |
| 84 | +## SEXP: (dj-check-time-span "segment_name" "high_bound" "low_bound") |
| 85 | + |
| 86 | +Used to check if the named track was playing, or is scheduled to change, in the specified band of time. Time is always in seconds, and is added to the current time. The bounds can be left blank, in which case they will be set to the end and start of the timeline respectivley. |
| 87 | + |
| 88 | +Expected use is to line events up to musical transitions or to chain together segments. |
| 89 | + |
| 90 | +## SEXP: (dj-time-from-mark "return_unit" "return_type" "mark_check" "offset_amount" "offset_unit") |
| 91 | + |
| 92 | +Returns distance to a point in the musical structure in thousandths of a second, measure or beat. Highly configurable, see the in-fred documentation for details. |
| 93 | + |
| 94 | +Expected use is to line events up to the musical structure within a track. |
0 commit comments