Skip to content

Conversation

@rjtokenring
Copy link
Contributor

@rjtokenring rjtokenring commented Nov 11, 2025

Brick created for generate sounds based on wave form handling.

from arduino.app_bricks.sound_generator import SoundGenerator, SoundEffect

player = SoundGenerator(wave_form="square", sound_effects=[SoundEffect.adsr()])
player.start()

song = [
    ("E5", 0.125), ("E5", 0.125), ("REST", 0.125), ("E5", 0.125),
    ("REST", 0.125), ("C5", 0.125), ("E5", 0.125), ("REST", 0.125),
    ("G5", 0.25),  ("REST", 0.25),  ("G4", 0.25),  ("REST", 0.25),

    ("C5", 0.25),  ("REST", 0.125), ("G4", 0.25),  ("REST", 0.125),
    ("E4", 0.25),  ("REST", 0.125), ("A4", 0.25),  ("B4", 0.25),
    ("Bb4", 0.125), ("A4", 0.25),  ("G4", 0.125), ("E5", 0.125),
    ("G5", 0.125), ("A5", 0.25),  ("F5", 0.125), ("G5", 0.125),
    ("REST", 0.125), ("E5", 0.25),  ("C5", 0.125), ("D5", 0.125), ("B4", 0.25),
]
for note, duration in song:
    player.play_tone(note, duration)
from arduino.app_bricks.sound_generator import SoundGenerator, SoundEffect

player = SoundGenerator(master_volume = 0.8, bpm = 120, sound_effects=[SoundEffect.adsr()])
player.start()

music = [
    ("E5", 1/8), ("D#5", 1/8), ("E5", 1/8), ("D#5", 1/8), ("E5", 1/8),
    ("B4", 1/8), ("D5", 1/8),  ("C5", 1/8),  ("A4", 1/4),

    ("C4", 1/8), ("E4", 1/8),  ("A4", 1/8),  ("B4", 1/8),
    ("E4", 1/8), ("G#4", 1/8), ("B4", 1/8),  ("C5", 1/8),

    ("E4", 1/8), ("E5", 1/8),  ("D#5", 1/8), ("E5", 1/8), ("D#5", 1/8), ("E5", 1/8),
    ("B4", 1/8), ("D5", 1/8),  ("C5", 1/8),  ("A4", 1/4),

    ("C4", 1/8), ("E4", 1/8),  ("A4", 1/8),  ("B4", 1/4),
    ("E4", 1/8), ("C5", 1/8),  ("B4", 1/8),  ("A4", 1),
]
for note, duration in music:
    player.play(note, duration)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant