You can also play sounds and play multiple songs at the same time with the API.
All you need is a command computer or an advanced computer with a connected command block.
Download Composer + Audio API (a sample song is included):
pastebin get rrfPrUxT extract
You'll need to run this file to extract everything.
Once you've extracted everything, you can simply type composer and press enter to launch the composer.
You can also download the Audio API separately:
pastebin get tw2JcyaT audio
Screenshot:
What everything means:
1 - File name (used for saving and loading music)
2 - New song
3 - Load song from path
4 - Save song to path
5 - Play song
6 - Pause song
7 - Go to start
8 - Main volume
9 - Current channel
10 - Add channel
11 - Delete current channel
12 - Channel volume
13 - Channel output
14 - Channel sound - List of sounds that you can use
15 - Move view left
16 - Channel
17 - Move view right
18 - Time (you can scroll to move the view up or down)
19 - Note pitch
20 - Note volume
Key bindings:
This program plays a bass sound with the pitch E4:
-- Loads the Audio API
os.loadAPI("audio")
-- Sets output 1 to the commands API (exclusive to command computers)
audio.setOutput()
-- Plays note.bass with the pitch E4
audio.playSound("note.bass", audio.pitch.e4)
-- Unloads the Audio API
os.unloadAPI("audio")
This program plays the music in the file music.acp until it ends:
-- Load the Audio API
os.loadAPI("audio")
-- Sets output 1 to the commands API (exclusive to command computers)
audio.setOutput()
-- Loads the music into the variable music
local music = audio.loadMusic("music.acp")
-- Adds the music
audio.addMusic(music)
-- Sets music to be played
music.playing = true
-- While the music is playing (the music will automatically be stopped when it ends)
while music.playing do
-- Plays the music
audio.update()
-- Sleeps for 1/20 of a second
os.sleep(0.05)
end
-- Unloads the Audio API
os.unloadAPI("audio")
All functions are documented here:
audio.setOutput
audio.setVolume
audio.getVolume
audio.playSound
audio.addMusic
audio.removeMusic
audio.loadMusic
audio.update