Build a self-playing command contraption that uses random numbers to compose and visualize a non-stop musical performance in F# major.
SimulationsMusicMysticRainbowPurpleBlackDecorationServer LobbyLearningBlock displaysSummoned mobsBlock building (fill/setblock/clone)Sounds21+ commands
This command creation builds an automated musical gazebo that generates an endless, non-repeating melody in F# major. Every quarter second, a random number generator picks a note from the F# major pentatonic scale and plays it on a bell, supported by a warm bass chord and a rhythmic drum beat.
Each note is visualized in real time. A floating amethyst core hovers at the center of the stage, sending out colorful note particles and rising glowing crystals from a ring of six tuned pillars whenever their specific pitch is chosen.
/scoreboard objectives add c9_tick dummy/scoreboard objectives add c9_note dummy/scoreboard objectives add c9_beat dummy/fill ~-4 ~ ~-4 ~4 ~ ~4 minecraft:polished_blackstone_bricks/fill ~-2 ~ ~-2 ~2 ~ ~2 minecraft:chiseled_polished_blackstone/setblock ~ ~ ~ minecraft:jukebox/summon minecraft:block_display ~ ~1.8 ~ {Tags:["c9_gen","c9_core"],Glowing:1b,glow_color_override:16755200,block_state:{Name:"minecraft:amethyst_cluster"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[1.2f,1.2f,1.2f],translation:[-0.6f,-0.5f,-0.6f]}}/summon minecraft:block_display ~3 ~0.5 ~ {Tags:["c9_gen","c9_p0"],Glowing:1b,glow_color_override:16724787,block_state:{Name:"minecraft:red_stained_glass"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,1.5f,0.8f],translation:[-0.4f,0f,-0.4f]}}/execute positioned ~1.5 ~0.5 ~2.6 run summon minecraft:block_display ~ ~ ~ {Tags:["c9_gen","c9_p1"],Glowing:1b,glow_color_override:16755200,block_state:{Name:"minecraft:orange_stained_glass"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,1.7f,0.8f],translation:[-0.4f,0f,-0.4f]}}/execute positioned ~-1.5 ~0.5 ~2.6 run summon minecraft:block_display ~ ~ ~ {Tags:["c9_gen","c9_p2"],Glowing:1b,glow_color_override:16777045,block_state:{Name:"minecraft:yellow_stained_glass"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,1.9f,0.8f],translation:[-0.4f,0f,-0.4f]}}/execute unless entity @e[tag=c9_p3] run summon minecraft:block_display ~-3 ~0.5 ~ {Tags:["c9_gen","c9_p3"],Glowing:1b,glow_color_override:5635925,block_state:{Name:"minecraft:lime_stained_glass"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,2.1f,0.8f],translation:[-0.4f,0f,-0.4f]}}/execute unless entity @e[tag=c9_p4] run summon minecraft:block_display ~-1.5 ~0.5 ~-2.6 {Tags:["c9_gen","c9_p4"],Glowing:1b,glow_color_override:5636095,block_state:{Name:"minecraft:cyan_stained_glass"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,2.3f,0.8f],translation:[-0.4f,0f,-0.4f]}}/execute unless entity @e[tag=c9_p5] run summon minecraft:block_display ~1.5 ~0.5 ~-2.6 {Tags:["c9_gen","c9_p5"],Glowing:1b,glow_color_override:11141290,block_state:{Name:"minecraft:purple_stained_glass"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,2.5f,0.8f],translation:[-0.4f,0f,-0.4f]}}/scoreboard players add @e[tag=c9_core] c9_tick 1/execute as @e[tag=c9_core,scores={c9_tick=5..}] run scoreboard players add @s c9_beat 1/execute as @e[tag=c9_core,scores={c9_tick=5..}] store result score @s c9_note run random value 0..5/execute as @e[tag=c9_core,scores={c9_tick=5..,c9_note=0}] at @e[tag=c9_p0] run playsound minecraft:block.note_block.bell master @a ~ ~ ~ 2 0.5/execute as @e[tag=c9_core,scores={c9_tick=5..,c9_note=1}] at @e[tag=c9_p1] run playsound minecraft:block.note_block.bell master @a ~ ~ ~ 2 0.561231/execute as @e[tag=c9_core,scores={c9_tick=5..,c9_note=2}] at @e[tag=c9_p2] run playsound minecraft:block.note_block.bell master @a ~ ~ ~ 2 0.629961/execute as @e[tag=c9_core,scores={c9_tick=5..,c9_note=3}] at @e[tag=c9_p3] run playsound minecraft:block.note_block.bell master @a ~ ~ ~ 2 0.749154/execute as @e[tag=c9_core,scores={c9_tick=5..,c9_note=4}] at @e[tag=c9_p4] run playsound minecraft:block.note_block.bell master @a ~ ~ ~ 2 0.840896/execute as @e[tag=c9_core,scores={c9_tick=5..,c9_note=5}] at @e[tag=c9_p5] run playsound minecraft:block.note_block.bell master @a ~ ~ ~ 2 1.0/execute as @e[tag=c9_core,scores={c9_tick=5..}] at @s run particle minecraft:note ~ ~0.4 ~ 1.8 0.8 1.8 1 12 force/execute as @e[tag=c9_core,scores={c9_tick=5..}] at @s run playsound minecraft:block.note_block.basedrum master @a ~ ~ ~ 0.8 1.0loop #6 Every 5 ticks (4 times per second), the <code>/random value 0..5</code> command rolls a random number between 0 and 5 and saves it into the core entity's <code>c9_note</code> score.loop #7 Each of the six possible numbers corresponds to a pitch in the F# major pentatonic scale (0.5 is F#3, 0.561231 is G#3, 0.629961 is A#3, 0.749154 is C#4, 0.840896 is D#4, and 1.0 is F#4). Using a pentatonic scale ensures that any random note sequence sounds consonant and musical.loop #13 When a note triggers, colorful note particles burst around the central amethyst core and a base drum sound keeps a steady tempo. Note that you should add one final chain command block with <code>/scoreboard players set @e[tag=c9_core,scores={c9_tick=5..}] c9_tick 0</code> to reset the 5-tick timer.


Recorded on our own test server: 59 frames at about 9.8 fps. Our image check saw: A blackstone platform with glowing rainbow-outlined pillars, a central glowing amethyst cluster, and colorful music note particles floating around.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
This contraption works automatically as an ambient musical fountain, so no player stand-in is needed. If you want to let players control the tempo, change the c9_tick=5.. condition in the loop commands to a higher number like 8.. for a slower song, or 4.. for a fast upbeat melody.
/kill @e[tag=c9_gen]/fill ~-4 ~ ~-4 ~4 ~ ~4 minecraft:air/scoreboard objectives remove c9_tick/scoreboard objectives remove c9_note/scoreboard objectives remove c9_beatThe six pitches are tuned to the F# major pentatonic scale (F#, G#, A#, C#, D#, and high F#). Because a pentatonic scale removes the half-step intervals that cause dissonance, any random order of notes forms a pleasant melody.
Yes! Replace minecraft:block.note_block.bell in the loop commands with another instrument like minecraft:block.note_block.chime, flute, harp, or bit.
/execute/fill/particle/playsound/random/scoreboard/setblock/summon
▶Four-Dimensional Hypercube Tesseract RotationSimulationsExpert24 cmds
▶Magnetic Ferrofluid Audio VisualizerSimulationsHard24 cmds
▶Harmonic Pendulum Wave ArraySimulationsMedium24 cmds
▶Alchemical Homunculus Vitro GenesisSimulationsHard25 cmds
▶Bioluminescent Mycelium Spore Network PulseSimulationsMedium24 cmds
▶Chronos Sundial Shadow Time-LapseSimulationsHard24 cmds