Skip to content

Tutorials · Sound and Music · Chapter 8

The bell

35 minutes Uses: AudioSource, AudioMix, Area, play_sound, pressed, in_group

By the end

  • A bell in its chamber that E rings while the knight stands by it, one toll at a time, by Max Voices
  • A Ducking row: while Sfx is over -18.4 dB, Music comes down 9 dB, on over about a fifth of a second and back over a few
  • Why every other sound on Sfx sits under the duck’s Threshold
  • A Sends row from Music to Sfx, and each snapshot’s Send Amounts: the music rings in the cave, and nowhere else
On this page

A bell to ring

In the bell chamber, south of the flooded passage, hangs a bell. Its sound came with the starter: bell.wav, a bronze bell struck once, a low A that rings on for two or three seconds and dies away over six.

  1. In Assets, click bell.wav in audio, set its Stream to Never in Details, and press Save. At six seconds Auto would stream it; a sound struck on a key is held whole, so each strike starts at once.
  2. Select bell, in bell_chamber. Press Add component and choose AreaComponent. In its Shape, set Size to 48, 48: the floor round the bell. Leave its Layer and Mask as they come.
  3. Press Add component and choose AudioSourceComponent. Leave Clip empty, Bus on Sfx, Volume at 1, Positional ticked, Max Distance at 512 and Rolloff on Quadratic, as they come. Set Min Distance to 48 and Max Voices to 1.
  4. Add a trigger toll, its Clip bell.wav.
  5. In Assets, click Assets in the path bar, so the script is written at the project’s top, then click Create, choose New script, type bell and press Enter. In the Code tab, replace everything in bell.rgs with the script below, and press Ctrl+S.
  6. Select bell, press Add component and choose Bell. Press Ctrl+S.
rgs bell.rgs
/// The bell in its chamber. The knight rings it standing by it, as often as
/// he likes: each toll rings on for several seconds, and the music dips under
/// it while the ring is loud.
component Bell : Area {
    /// How many knights stand by it.
    #[readonly]
    near: i32 = 0,

    fn on_enter(other: NodeId) {
        if in_group(other, "knight") {
            near += 1;
        }
    }

    fn on_exit(other: NodeId) {
        if in_group(other, "knight") {
            near -= 1;
        }
    }

    fn loop() {
        // E, which the input map calls action, pressed while he stands by it.
        if near > 0 && pressed("action") {
            play_sound("toll");
        }
    }
}
The Inspector’s column, widened and narrowed to audio, on bell: AudioSourceComponent with Clip (none), Bus Sfx, Volume 1.000, Pitch 1.00, Looping and Autoplay unticked, Spatial with Positional ticked, Max Distance 512.00, Blend 1.000, Rolloff Quadratic, Min Distance 48.00 and Pan 0.000, Max Voices 1; Triggers with one item, 1 toll open: Name toll, Clip bell.wav, Clips with no items, Mode Shuffle, Pitch and Volume each Min 1.00 and Max 1.00
The bell’s Audio Source: no sound of its own, Min Distance 48, Max Voices 1, and toll.
The game with the knight in the bell chamber, standing just above the golden bell on the floor, lit warm by his lantern, a gravestone in each of the room’s corners and the door to the flooded passage in its north wall
Where he rings it: standing by the bell, inside its Area.

near counts the knights inside the bell’s Area: on_enter adds one, on_exit takes one away. #[readonly] shows it in the Inspector, as Near, and keeps it out of your hands: the game writes it. E is action, the key chapter 4 gave the lever: the bell and the lever each listen for it only while he stands by them.

The music dips under it

The bell is a moment the game wants heard. A Ducking row holds one bus down while another is loud: here Music under Sfx. While the bell rings loud, the music steps aside; as the ring dies, it comes back.

  1. Select mix. Press + beside Ducking: a row, 1, reading Sfx>Music as a row comes, its Trigger Sfx and its Target Music. Open it.
  2. Set Threshold to -18.4, Amount to 9, and Release to 1. Leave Attack at 0.05.
  3. Press Ctrl+S.
The Audio Mix’s Ducking
Rules that hold one bus down while another is loud, a row each. The Inspector reads each by its place and its two buses, 1 and Sfx>Music, the bus that listens first.
A duck’s Trigger
The bus it listens to: here Sfx, the whole bus, after its chain. It hears the bus, not the bell: anything on Sfx loud enough would duck the music too. Not Master, the sum of everything it would duck: a row whose Trigger is Master is dropped, and the Problems tab says so.
A duck’s Target
The bus it holds down: here Music. A bus cannot be both: a row whose Target is its Trigger is dropped, and the Problems tab says so, as below.
A duck’s Threshold
How loud the Trigger must be for the duck to come on, in decibels under full scale, from -96 to 0. The bell’s ring reads over -18.4 on the Sfx meter for its first three seconds and more; nothing else in the crypt reaches it.
A duck’s Amount
How many decibels come off the Target while the Trigger is over its Threshold: 9, which leaves the music at a little over a third of its level. From 0 to 96.
A duck’s Attack
How quickly the duck comes on once the Trigger goes over, in seconds. It is a time constant, not a ramp: at 0.05, the duck is most of the way on in a twentieth of a second and all but fully on in about a fifth.
A duck’s Release
How quickly it lets go once the Trigger falls back under, in seconds, a time constant too: at 1, the music is most of the way back in a second and all but back in about four, so it rises with the ring as it dies rather than jumping back.

Press F5, walk down through the passage’s south door into the bell chamber, stand by the bell and press E.

By the bell, where nothing else on Sfx is heard; a second and a half in, E rings it. Listen for the music dropping under the bell as it strikes, staying down while the bell rings loud, and coming back up as the ring dies away, from about three and a half seconds after the strike.
What it sounds like

Calm music alone; a deep bell is struck and rings, and the music sinks under it; the ring slowly fades over about six seconds, and the music swells back to where it was.

The Sound tab’s meters 2.5 s into Play by the bell, with nothing rung: Master and Music each -29.0 dB, peak -21.3; Sfx silent
By the bell at 2.5 s, with nothing rung: Music at -29.0 dB, Sfx silent.
The same moment a second after E rang the bell: Master -15.7 dB, peak -12.3; Music -37.9 dB, peak -30.3; Sfx -16.0 dB, peak -13.0
The same moment, a second into the toll: Sfx over the Threshold at -16.0 dB, and Music 8.9 dB down.

The two pictures are the same moment of two runs, alike but for E: the music is the same music, and the duck has it 8.9 dB under. Over the whole toll the music is down by about the Amount from a fifth of a second after the strike until the ring falls under the Threshold, and within a decibel of where it was some four seconds after that.

The Problems tab with one warning: mix, Ducking rule 1 (Sfx ducking Sfx) is dropped: a bus cannot be both the trigger and the target of a duck — give it a Trigger that is not Master, and a Target that is not its Trigger
The Problems tab with the row’s Target set to Sfx, its own Trigger: the row is dropped, and the music never dips.

Everything else, under it

The duck hears the whole Sfx bus, after its Compressor. Every loud one-shot there sits near the Compressor’s -15 dB, so a Threshold of -18.4 would be crossed by any of them that came close. That is why Part 1 set them as low as it did: the doors at 0.5, the bridge at 0.4, the gate’s grind and thud at 0.3, the lever at 0.25, and the music box at 0.3. Walking the whole crypt, his steps, the torches, the doors, the bridge, the gate and the waterfall never move the duck: the bell is the one thing on Sfx loud enough to dip the music.

The music in the cave

The cave’s Reverb is on Sfx, so it rings what is in the room and not the music. A Sends row feeds some of one bus into another’s chain: some of the music through Sfx’s, so that in the cave it passes the Reverb and the room answers it too. It is fed at nothing, and each snapshot says how much.

  1. Select mix. Press + beside Sends: a row, 1. Open it, and set From to Music and To to Sfx. Leave its Amount at 0.
  2. Open the snapshot cave, and press + beside its Send Amounts: an amount for the row, reading Music>Sfx, at the row’s own 0. Set it to 0.5.
  3. In passage and in well, press + beside Send Amounts and leave each at 0.
  4. Press Ctrl+S.
The Inspector’s column, widened and narrowed to audio, on mix with Effects shut: Snapshots with three items, 1 cave open, Name cave, Master Volume 1.000 with Compressor ticked and LowPass unticked, Music Volume 1.000 with Gain ticked, Sfx Volume 1.000 with Compressor ticked, Panner unticked, Reverb ticked and Delay unticked, and Send Amounts with one item, 1, 0.50 Music>Sfx; 2 passage and 3 well shut; Ducking with one item, 1 Sfx>Music open: Trigger Sfx, Target Music, Threshold -18.4 dB, Amount 9.0 dB, Attack 0.05 s, Release 1.00 s; Sends with one item, 1 open: From Music, To Sfx, Amount 0.000
The crypt’s mix: the Ducking row, the Sends row at 0, and the cave’s Send Amounts, 0.5.
The Audio Mix’s Sends
Rows that feed some of one bus into another, a row each. A sent copy is heard where it ends, on Master, and not on the bus it is fed through: the Sfx meter, which the duck listens to, never hears the music, so the music cannot duck itself.
A send’s From
The bus that is tapped, after its own chain and fader: here Music.
A send’s To
The bus whose chain the copy is fed through, and then its volume: here Sfx, for its Reverb. So the music’s ring in the cave follows the options’ Sfx slider as well as the Music one.
A send’s Amount
How much of the bus is sent, from 0 to 1: the row’s own, used wherever a snapshot says nothing. Here 0: no snapshot but the cave’s sends anything.
A snapshot’s Send Amounts
How much each of the mix’s Sends carries in this snapshot, an amount for each row by its place, read with the row’s two buses, Music>Sfx. A list shorter than the Sends leaves the rest at their own Amount. The cave’s 0.5; the passage’s and the well’s 0, the row’s own, written out so the Inspector shows them.

Stand in the cave’s east side, and listen.

Seven seconds in the cave’s east side, as the chapter has it: the music sent through the cave’s Reverb. Compare it with the clip below.
What it sounds like

The calm music-box melody over its soft pad, with a faint hall-like wash behind it, and the waterfall’s distant roar.

The same seven seconds with the cave’s send left at nothing. Listen for the music a little quieter here, and without the room’s ring behind it.
What it sounds like

The same calm music, a little quieter and plainer, and the same distant roar.

The send’s copy of the music is about half dry, the Reverb’s Mix, and half the room’s ring of it. So in the cave the music is a little under 2 dB louder than without the send, and the ring under it is some 16 dB under the music: heard, and never in the way. Below the cave’s door, in no zone, the send carries nothing, and the music is as it was.

Who decides what you hear

The bell and the send

NodeComponentFieldValue
audio/bell.wavits DetailsStreamNever
bellAreaShape Size48, 48
Audio SourceClip, Bus, Volumenone, Sfx, 1
Positional, Max Distance, Rolloffticked, 512, Quadratic
Min Distance, Max Voices48, 1
trigger tollClip bell.wav
Bellbell.rgs
mixAudio MixDucking row 1Sfx over Music: -18.4 dB, 9 dB, 0.05 s, 1 s
Sends row 1Music to Sfx, Amount 0
Send Amountscave 0.5, passage 0, well 0

Check it works