Shop OBEX P1 Docs P2 Docs Learn Events
How should data be formated for a frequency file? — Parallax Forums

How should data be formated for a frequency file?

KyeKye Posts: 2,200
edited 2009-05-25 16:25 in Propeller 1
Hey all,

I've been working on a sound driver that lets the propeller chip generate a 1-22050 Hz on an I/O pin. That I/O pin is then pluged into an amplifier which controls a speaker.

The results so far are great, I can play any tone (frequency) that I want (I can't hear them all however) and I can play them for any amount of time that I want.

Now, the next step in the developement cycle is to make the speaker play from a data table full of tones to generate a song. I've already come up with a simple format for this which uses a table built like this.

word (frequency)
word (time in milliseconds to play the frequency)
word (frequency)
word (time in milliseconds to play the frequency)

word ...
word ...
 
etc.


However, I'm not sure if this is the best way to control the tone the speaker plays.

All I can control is the frequency which I send to the speaker and the time that I send it for.

...So is there any standardized filetype out there that works with only the frequency and time to play music?

I want to try to make the driver easily usable with already established file types. So if anyone knows either a better way to format·the data table for a song or a standard file type for this please speak up.

Thanks,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Comments

  • jazzedjazzed Posts: 11,803
    edited 2009-05-24 00:00
    Google RTTTL ... ring tone format. Some Hydra games use it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-24 01:21
    Kye,

    It depends on your objective. If it's just to play music (using a Western scale), the frequencies are bound by 12 semitones per octave (C to C), and the durations by powers of two and their dotted complements. You also need to consider playing styles, such as legato, marcato, staccato, glissando, etc., as well as by overall tempo. The user documentation for the SoundPAL may give you some ideas.

    There's also the ABC notation, along with the aforementioned RTTTL.

    -Phil
  • KyeKye Posts: 2,200
    edited 2009-05-24 05:33
    Ah okay, I see, using notes instead of just frequencies makes alot more sense too.

    Thanks,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • KyeKye Posts: 2,200
    edited 2009-05-24 05:41
    So making a RTTTL to the type of data format I currently have would be smarter or stupider? The driver I'm making also runs a DAC and ADC for mono 16 bit PCM data so I'm not sure if it will have enough time to fiddle arround with ASCII bytes and such.

    Does that sound like a good idea? Making a converter?·It would then make the driver more flexible and able to play any higher level data type format.

    Thanks,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • jazzedjazzed Posts: 11,803
    edited 2009-05-24 16:08
    Look for hydra_rtttl* and sound_test_bed* here: www.parallax.com/Portals/0/Downloads/sw/HYDRASourceCodeDemos.zip
    To my eyes the code is clumsy and big, but there are tons of tones out there and all kinds of PC converter and composer programs.
    If you want something small and probably limited, you'll have to use a proprietary form.

    SoundPAL notation looks pretty compact. It could use a Spin interpreter and PC tool set ....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • parts-man73parts-man73 Posts: 830
    edited 2009-05-24 17:33
    www.andrewarsenault.com/hss/index.html

    This is another existing format for sound files on the Propeller

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio - the modular Development system for the Propeller

    PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!

    SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
  • KyeKye Posts: 2,200
    edited 2009-05-25 16:25
    Ah, very nice, guys.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
Sign In or Register to comment.