On this page:
8.1 (sound ....) syntax
8.2 Unit helper functions

8 Sound effects

You specify sound effects within an (effect ....) expression using the

(sound ....)

form. Here is a sample sound effect specification -
(effect ....
    (sound  "sfx/000-funny-sound-2.04.mp3"
            time-scale: (smpte 7.1)
            start: (smpte 4.01)
            mstop: (smpte 2.04)
            volume: (dB -6)))

The sound function gets values from its argument list using a keyword-based approach because in this case there are too many values for visual comfort while reading the specification.

Notice that the sound form can only be specified within an (effect ....) expression. This means it has to be explicitly related to some part of the muvee such as a segment or a transition. You can also specify sound effects globally within any global effect. The reason for this association is that sound effects are generally placed relative to significant points in the music and effect placement automatically gives you access to these significant point. Also, since effects are time limited, the sound specified within an effect is also automatically time limited (or not) depending on the parameters that were provided.

8.1 (sound ....) syntax

The syntax of the sound function is as follows -

(sound relative-path-to-file keyword1: value1 keyword2: value2 ...)

The relative-path-to-file is a string giving a path to an mp3 file relative to the style’s package folder. All keyword-value pairs are optional and have default behaviour when unspecified. Note that keywords have a “:” character as suffix to distinguish them from normal symbols.

The following keywords are available -

time-scale:

The value relative to which playback times are specified. Defaults to 1.0.

start:

The relative time (w.r.t. time-scale) at which to start playing the sound. Defaults to start of effect - i.e. 0.0.

stop:

The relative time at which to stop playing the sound. To let it play for as long as it can, omit this parameter. If you omit it, you must specify the mstop: parameter.

fade-in:

The relative time for which the sound must fade in after start of play. Defaults to 0.0.

fade-out:

The relative time for which the sound must fade out before end of play. Defaults to 0.0.

mstart:

The position (in seconds) within the sound file from which to start playback. Defaults to start of sound file - i.e. 0.0 seconds.

mstop:

The position (in seconds) within the sound file until which to play. If you want to stop at a time determined by the stop: keyword, then don’t specify this value. If you don’t specify this, then you must have specified stop:.

pitch:

A pitch correction value for adjusting the sound’s playback speed. The correction value is given in octaves, so that 0.0 means “no change”, 1.0 means “double the speed” and -1.0 means “half the speed”. Defaults to 0.0.

volume:

A volume adjustment factor. It specifies a multiplier for the amplitude of the sound clip. Defaults to 1.0.

8.2 Unit helper functions

(smpte t)  time-in-seconds
  t : SMPTE-time
Used to convert a smpte time specification into seconds. For example, (smpte 4.15) stands for the absolute time “4.5 seconds”. Here’s how the “4.15” is converted to “4.5” - 4 + (0.15 / 0.3).

(dB level)  fraction
  level : number
Used to convert a dB value to a multiplication factor. (dB -3.0) will give you 0.5.
(semitones s)  number-in-octaves
  s : number-in-semitones
Used to convert a semitone value to octaves. (semitones 2) will give you 2/12. If you don’t mind the explicit 12, you can directly use the constant fraction expression 1/6 instead of (semitones 2).