Skip to content

Commit

Permalink
Added demo CEL/CELX scripts and sounds
Browse files Browse the repository at this point in the history
Added .cel and .celx scripts for demonstration audio playback (with demo
sound).
  • Loading branch information
Alexell committed Mar 20, 2017
1 parent 37ed932 commit 4fb86d9
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 0 deletions.
98 changes: 98 additions & 0 deletions scripts/audio/sound_demo.cel
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# --------------------------------------------------------------------------------------------------
# This file demonstrates the 'play' command
# First patch for audio support in Celestia by Victor (vhpgomes).
# Patch modification by Vincent (added pause/resume parameters).
# Patch modification by Alexell (added pan parameter and adapted for FMOD library).
# First patch information: https://celestiaproject.net/forum/viewtopic.php?t=8624
#
# This command accepts 6 arguments:
#
# play { channel [int] volume [float] pan [float] loop [int] filename [str] nopause [int] }
#
# channel - specifies the channel that'll be affected by this call.
# If not given, will assume the default value of 0, You can provide any number between 0 and 7.
# Any number out of this range will cause the script to fail.
#
# volume - specifies the new volume of this channel. If not given, the volume of the channel will remain unchanged.
# It starts with the volume 1.0. You can specify any number between 0.0 (minimum, mute) and 1.0 (maximum).
# If the number given is negative, the value is ignored, and the volume remains unchanged.
# If the number is bigger than 1.0, the volume will be set to the maximum volume, 1.0.
#
# pan - specifies the pan for the channel.
# If not given, the sound will be centered (default value of 0).
# The level relationship between the left and right channels must be specified in the range
# from -1.0 to 1.0. The value -1.0 is only the left channel. The value 0.0 is centered.
# Value 1.0 is just the right channel.
#
# loop - specifies if the sound file will loop or not.
# If not given, the looping mode of the channel will remain unchanged.
# It starts with looping off. The value 1 turns the looping on. Any other value turns the looping off.
#
# filename- name of the file that will be played. If only the file name is specified, then the subfolder "sounds" is searched.
# I.e. in this case the path is relative to the directory "Celestia\sounds".
# If the file is located in a different folder, you must specify the full path to it.
#
# nopause - parameter that allows a particular sound channel to be paused or not paused on any channel when the spacebar is pressed.
# Value 0 - allow pause by spacebar, value 1 - disallow.
# --------------------------------------------------------------------------------------------------

{
print { origin "bottomleft" row -5 column 3 duration 5 text "Welcome!\n\nYou start an audio playback script." }
wait { duration 5 }

play { channel 0 volume 1 pan 0 loop -1 filename "music.mp3" nopause 1 }

#Since we used the default values for some parameters, we could use the abbreviated version of the command:
#play { channel 0 filename "music.ogg" nopause 1 }

wait { duration 2 }
print { origin "bottomleft" row -3 column 3 duration 5 text "Background music playing (channel 0)." }
wait { duration 8 }


play { channel 1 loop 0 filename "comment.mp3" }

wait { duration 2 }
print { origin "bottomleft" row -3 column 3 duration 5 text "Voice comments (channel 1)." }
wait { duration 5 }

#Set the channel 0 panorama to the left speaker
play { channel 0 pan -1.0 }

#Wait for 5 seconds
wait { duration 5 }

# ... and set the channel 0 panorama to the right speaker
play { channel 0 pan 1.0 }

#Wait for 5 seconds
wait { duration 5 }
# ... and set the channel 0 panorama to the center
play { channel 0 pan 0 }
wait { duration 2 }

print { origin "bottomleft" row -3 column 3 duration 5 text "Simultaneously, you can play 8 channels (0-7)." }
wait { duration 7 }
print { origin "bottomleft" row -3 column 3 duration 8 text "Now smoothly reduce the volume of the channel 0." }

#Now smoothly reduce the volume level of channel 0, over which we have background music.
play { channel 0 volume 0.8 }
wait { duration 2 }
play { channel 0 volume 0.6 }
wait { duration 2 }
play { channel 0 volume 0.4 }
wait { duration 2 }
play { channel 0 volume 0.2 }
wait { duration 2 }
play { channel 0 volume 0.1 }
wait { duration 2 }

#Before the script ends, you need to stop the playback of the running channels (filename = "").
play { channel 0 filename "" }
play { channel 1 filename "" }


print { origin "bottomleft" row -5 column 2 duration 5 text "End of script..." }
wait { duration 5 }

}
87 changes: 87 additions & 0 deletions scripts/audio/sound_demo.celx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
-- ------------------------------------------------------------------------------------------------------
-- This file demonstrates the 'celestia:play' command
-- First patch for audio support in Celestia by Victor (vhpgomes).
-- Patch modification by Vincent (added pause/resume parameters).
-- Patch modification by Alexell (added pan parameter and adapted for FMOD library).
-- First patch information: https://celestiaproject.net/forum/viewtopic.php?t=8624
--
-- This command accepts 6 arguments:
--
-- celestia:play ( int [channel], float [volume], float [pan], int [loop], str [filename], int [nopause] )
--
-- channel - specifies the channel that'll be affected by this call.
-- If not given, will assume the default value of 0, You can provide any number between 0 and 7.
-- Any number out of this range will cause the script to fail.
--
-- volume - specifies the new volume of this channel. If not given, the volume of the channel will remain unchanged.
-- It starts with the volume 1.0. You can specify any number between 0.0 (minimum, mute) and 1.0 (maximum).
-- If the number given is negative, the value is ignored, and the volume remains unchanged.
-- If the number is bigger than 1.0, the volume will be set to the maximum volume, 1.0.
--
-- pan - specifies the pan for the channel.
-- If not given, the sound will be centered (default value of 0).
-- The level relationship between the left and right channels must be specified in the range
-- from -1.0 to 1.0. The value -1.0 is only the left channel. The value 0.0 is centered.
-- Value 1.0 is just the right channel.
--
-- loop - specifies if the sound file will be played in looping or not.
-- If not given, the looping mode of the channel will remain unchanged.
-- It starts with looping off. The value 1 turns the looping on. Any other value turns the looping off.
--
-- filename- name of the file that will be played. If only the file name is specified, then the subfolder "sounds" is searched.
-- I.e. in this case the path is relative to the directory "Celestia\sounds".
-- If the file is located in a different folder, you must specify the full path to it.
--
-- nopause - parameter that allows a particular sound channel to be paused or not paused on any channel when the spacebar is pressed.
-- Value 0 - allow pause by spacebar, value 1 - disallow.
-- ------------------------------------------------------------------------------------------------------

celestia:print ( "Welcome!\n\nYou start an audio playback script.", 5.0, -1, -1, 3, 5 )
wait (5)

celestia:play ( 0, 1, 0, -1, "music.mp3", 1 )

wait (2)
celestia:print ( "Background music playing (channel 0).", 5.0, -1, -1, 3, 3 )
wait (8)

celestia:play ( 1, 1, 0, 0, "comment.ogg" )

wait (2)
celestia:print ( "Voice comments (channel 1).", 5.0, -1, -1, 3, 3 )
wait (5)

--Set the channel 0 panorama to the left speaker
celestia:play ( 0, 1, -1 )
-- Wait for 5 seconds
wait (5)
-- ... and set the channel 0 panorama to the right speaker
celestia:play ( 0, 1, 1 )
-- Wait for 5 seconds
wait (5)
-- ... and set the channel 0 panorama to the center
celestia:play ( 0, 1, 0 )
wait (2)

celestia:print ( "Simultaneously, you can play 8 channels (0-7).", 5.0, -1, -1, 3, 3 )
wait (7)
celestia:print ( "Now smoothly reduce the volume of the channel 0.", 8.0, -1, -1, 3, 3 )

-- Now smoothly reduce the volume level of channel 0, over which we have background music.
celestia:play ( 0, 0.8 )
wait (2)
celestia:play ( 0, 0.6 )
wait (2)
celestia:play ( 0, 0.4 )
wait (2)
celestia:play ( 0, 0.2 )
wait (2)
celestia:play ( 0, 0.1 )
wait (2)

-- Before the script ends, you need to stop the playback of the running channels (filename = "").
celestia:play ( 0, -1, 0, 0, "" )
celestia:play ( 1, -1, 0, 0, "" )

celestia:print ( "End of script...", 8.0, -1, -1, 3, 5 )
wait (8)
2 changes: 2 additions & 0 deletions sounds/Info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This folder for placing audio files that will be used by the play / celestia:play command in the CEL / CELX scripts.
If necessary, you can create subfolders to organize and classify audio files for various needs.
Binary file added sounds/comment.mp3
Binary file not shown.
Binary file added sounds/music.mp3
Binary file not shown.
Binary file added sounds/space.mp3
Binary file not shown.

0 comments on commit 4fb86d9

Please sign in to comment.