Shop OBEX P1 Docs P2 Docs Learn Events
RTTTL — Parallax Forums

RTTTL

Has anyone got an RTTTL player written in SPIN for the Propeller 1 ?

Comments

  • JonnyMacJonnyMac Posts: 9,156
    edited 2024-12-06 15:49

    I had to look up RTTTL player. :D

    I've never done that, but I did create a simple musical note player with the P1 that I've used in laser tag and escape room props. The program runs a background code in a 1ms loop that can read and play monotonic notes from a DAT table. If this interests you, I'll dig the player code out of one of my work projects so you can use it.

  • Thanks Jon.

    Though the RTTTL player remains quite appealing, given the 1000's of standard ringtones and tunes out on the webs.

    I've since found an old PBASIC implementation that might be fun to convert. And also mention on this forum of an .SPIN RTTTL player as part of the old Hyrda CD collection; although I've not found the sources yet; I don't have that CD... Poop!

    Anyway- the .bs2 seems simple enough to re-create. Needs some more research first- I'm still looking for a nice article that explains the protocol fundamentals - please share if you come across a good one!

    And then with that... My daughter just made Mac'n'cheese for the first time, so that's suddenly distracting me...... tasting that seems to have become a greater priority for today ! I was rather sceptical of all that cheese, but it's surprisingly yummy - especially with a dash of hot sauce!

  • Oh... look's like Phil (RIP) was active with RTTTL at some point. Really sad that his creations have slipped away:
    https://forums.parallax.com/discussion/98934/rtx-rtttl-ringtone-to-soundpal-code-converter

  • JonnyMacJonnyMac Posts: 9,156
    edited 2024-12-06 16:38

    Well, I scraped out my player code, anyway, and have attached it here. Maybe it can help in implementing a background RTTTL player in Spin. This does have the code to playing specific notes using the P1 timer module.

  • Neat! That's a familiar tune !!
    Thanks Jon.

  • maccamacca Posts: 806

    @VonSzarvas said:
    I've since found an old PBASIC implementation that might be fun to convert. And also mention on this forum of an .SPIN RTTTL player as part of the old Hyrda CD collection; although I've not found the sources yet; I don't have that CD... Poop!

    I found the attached sources, hope it is what you are searching.

  • @VonSzarvas said:
    I've since found an old PBASIC implementation that might be fun to convert. And also mention on this forum of an .SPIN RTTTL player as part of the old Hyrda CD collection; although I've not found the sources yet; I don't have that CD... Poop!

    As always, I am playing 6D chess five turns ahead: https://github.com/Wuerfel21/HydraCD

  • VonSzarvasVonSzarvas Posts: 3,484
    edited 2024-12-06 19:32

    Ace, thank you for the music!!

    Seems though the Hyrda version targets a speaker, not a piezo.

    Is anyone familiar with how that works... how to alter the following to make a sensible noise from a Piezo buzzer...:

    Line ~535 of HYDRA_RTTTL_PLAYER_001b.SPIN
    snd.PlaySoundFM(channel, snd#SHAPE_SQUARE, rtl_note, snd_driver_duration, 255, $1357_DDEF)

    Line ~444 of NS_sound_drv_050_22khz_16bit

    PUB PlaySoundFM(arg_channel, arg_shape, arg_freq, arg_duration, arg_volume, arg_amp_env) | offset
    {{
    Starts playing a frequency modulation sound. If a sound is already
    playing, then the old sound stops and the new sound is played.
    
       arg_channel:   The channel on which to play the sound (0-5)
       arg_shape:     The desired shape of the sound. Use any of the
                      following constants: SHAPE_SINE, SHAPE_SAWTOOTH,
                      SHAPE_SQUARE, SHAPE_TRIANGLE, SHAPE_NOISE.
                      Do NOT send a SHAPE_PCM_* constant, use PlaySoundPCM() instead.
       arg_freq:      The desired sound frequncy. Can be a number or a NOTE_* constant.
                      A value of 0 leaves the frequency unchanged.
       arg_duration:  Either a 31-bit duration to play sound for a specific length
                      of time, or (DURATION_INFINITE | "31-bit duration of amplitude
                      envelope") to play until StopSound, ReleaseSound or another call
                      to PlaySound is called. See "Explanation of Envelopes and
                      Duration" for important details.
       arg_volume:    The desired volume (1-255). A value of 0 leaves the volume unchanged.
       arg_amp_env:   The amplitude envelope, specified as eight 4-bit nybbles
                      from $0 (0% of arg_volume, no sound) to $F (100% of arg_volume,
                      full volume), to be applied least significant nybble first and
                      most significant nybble last. See "Explanation of Envelopes and
                      Duration" for important details.
    }}
    
      offset := arg_channel*SIZE_OF_PARAM_CHDAT
    
      repeat until pending_shape[offset] == NOTHING_PENDING
    
      pending_duration[offset]  := arg_duration
      pending_volume[offset]    := arg_volume
      pending_freq[offset]      := arg_freq
      pending_amp_env[offset]   := arg_amp_env
      pending_shape[offset]     := arg_shape | CONSTANT(1<<31)
    

    Maybe Jon's driver is closer to having note playing capability over the fine high QTX+ gold-plated zero~plus oxygen audio driver I'm aiming for !

Sign In or Register to comment.