Shop OBEX P1 Docs P2 Docs Learn Events
SPIN Tone Generator — Parallax Forums

SPIN Tone Generator

RaymanRayman Posts: 14,364
edited 2008-11-22 05:14 in Propeller 1
I'm now learning how to do DAC with the Prop...

I've written this little·dual tone generator in SPIN.· Works from ~8 to 2000 Hz with a fixed 16 ksps rate.

It's set up to drive the stereo output of the Demo board.· Kinda fun to plug in speakers and mix frequencies...

I've seen that Tracy Allen has done something like this before, but this is my own·take on it (with fixed sample rate)...

I'm hoping to do a WAV player from SD card.· I think I could do this now at 16 ksps, but this isn't so great...· Definitely need assembly for descent quality...· Still, it might be fun to try it in SPIN...· I know David already did a WAV player in assembly.

Update:· Well, I just fixed a rookie error that made the output not quite as pretty a sine wave as it is now.· I've updated this post with the revised file.


Post Edited (Rayman) : 11/9/2007 1:44:13 PM GMT

Comments

  • hippyhippy Posts: 1,981
    edited 2007-11-09 03:04
    Good stuff.

    I'd love to see a more advanced interactive sound synthesizer similar to a AVRSYN ( or SoundGin ). With high-speed operation, multiple Cogs and shared Hub memory something quite impressive should be possible and MIDI control should be fairly easy to add. Make it SoundGin compatible and their visual programming software can be used wink.gif

    I've had some fun poking around and making noises out of Chip's Vocal Tract object and I guess Hydra Sound System FX Synth would be a good place to start, but it's a all a bit beyond me and I've got a long list of fun things to try with a Propeller first.

    The worst thing about the Propeller - It can easily consume your life smile.gif
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-11-09 04:35
    Looks like you've just created the basis for a DTMF dialer.. [noparse]:)[/noparse]
    nemesis.lonestar.org/reference/telecom/signaling/dtmf.html

    Not sure how accurate it is, but it sounded close.. If I had a phone closer to my prop, I'd test. [noparse]:)[/noparse]

    Remember those old portable DTMF dialer Radio Shack used to sell?


    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • RaymanRayman Posts: 14,364
    edited 2007-11-09 13:43
    I just found and fixed an error that made the sine wave not as pretty as it is now... I was addressing a long table with i instead of i*4...
  • hippyhippy Posts: 1,981
    edited 2007-11-12 04:45
    Looks like no one was taking a bite at the idea of creating a Music Synthesiser with the Propeller so I set about having a go. The results aren't brilliant but aren't too bad either considering it's just Spin and my first venture into anything approaching digital sound generation. Thanks to Rayman for the inspiration.

    The versions are the incremental steps I went through which hopefully makes it clearer what's going on for anyone, like I was, who's starting off clueless.

    Edit : See post two down for latest source code attachment.

    Post Edited (hippy) : 11/16/2007 4:16:56 PM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-11-12 05:27
    [noparse][[/noparse]Note to Self] Check volume before running hippy's audio code late at night. [noparse]:)[/noparse]


    Very Cool. It's neat to see some more sound stuff appearing!

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.

    Post Edited (Oldbitcollector) : 11/13/2007 5:35:49 PM GMT
  • hippyhippy Posts: 1,981
    edited 2007-11-13 17:30
    Added ADSR and AHDHSR Envelope Generators ( timing is screwed ), Ring Modulator and VCA.
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-11-14 13:48
    Anyone remember those old MOOG monophonic synthesizers with all the dials and sliders? I bet it's possible to build a replica around the Propeller. Wish I had more time on my hands.... I don't understand how anyone can be bored. I've never been bored my whole life! There is so much to do and so little time!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • BaggersBaggers Posts: 3,019
    edited 2007-11-14 15:06
    Ken, I know what you mean, I've absolutely no idea how people can be bored, well, they can when they don't have a prop to play with, but for us propheads, there just is never enough time in the day to do everything [noparse]:([/noparse] and yeah, I recon one of those old MOOG's could be done, even polyphonic, I can't sing this chips praises enough, it's just sooooooooooooooooooooooooooooooo versatile, this chip has been so very awe inspiring to so many people, it just gets the old grey matter back to life buzzing with weird and wonderful imagination, and creation. funny how I'm not even advertising for the prop, I'm just so greatful it's here [noparse]:)[/noparse]
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-11-14 15:40
    Between this code and the 8bit wav code from Rayman, a MOOG or even "Mellontron" is more than possible
    using a propeller. Who said they were bored??! If you are bored with a Propeller in the same house, you've
    got real issues.. <smirk> I wish I had more time to play myself...

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • hippyhippy Posts: 1,981
    edited 2007-11-14 19:17
    The code really needs to be converted to Assembler but it's not boredom stopping me just lack of time and other projects in the way. A 1kHz 256-step sine wave ideally needs a 4uS tick rate.

    SoundGin runs six VCO and six ADSR's plus Mixer on an 18F1320 at (probably) 10MIPs, so a Cog should be able to do twice as much. With a Cog for MIDI or keyboard scanning, another for mixing and scheduling/allocating notes, it should be possible to get twelve note polyphonic sound from one Propeller.

    As with SoundGin, the configuration should be able to do allophone speech, so that's potentially 12 Propeller 'conversations' going on at once smile.gif

    The VCO's use a Sine table but there's no reason any wave table couldn't be used, or that it couldn't use 'samples'.

    There's still scope for plenty of expansion in what I've done; Frequency Modulation being the main lacking feature, and I don't have a clue about how to implement digital filtering to emulate a VCF.

    This was really thrown together to see where it would go. Ultimately I think it would best be rewritten to be SoundGin compatible and that appears to do things in a different way. That gets round the problem of not having lots of pots and sliders, MIDI or a keyboard for testing or use.

    Post Edited (hippy) : 11/14/2007 7:23:17 PM GMT
  • hippyhippy Posts: 1,981
    edited 2007-11-16 16:11
    The most annoying thing about the Propeller is that when one starts it's so hard to stop ...

    Tone Generator re-written in Assembler attached. It emulates almost all of the Soundgin functionality for a main oscillator, max frequency is 7,812Hz with a 64uS tick rate at 80MHz. That's enough to handle 12 oscillators so each Cog should be able to emulate one Soundgin each. Going to 96MHz would be the obvious solution if it gets tight or the tick rate can be upped to 100uS ( 5,000Hz ) with little noticeable affect on the sound quality at 1kHz.

    The oscillators and mixers need to run once per tick for quality but ADSR's and other ramping / targeting controls can probably be sequentially run one per tick which keeps the per loop overhead down. About 40% of the Cog is used so far, generally unoptimised code.

    One Cog for TV text, one for TV diagnostic reports, one for serial / MIDI / keyboard scanning, one for serial command processing, leaves four for music generation. The TV Cogs could be reclaimed for music use. So that's four to six note polyphonic with a Soundgin per Cog and allocating Cogs for different functions ( VCO / ADSR ) would increase that. I'm aiming for a single Soundgin per Propeller emulation to start with; five Cogs including TV.

    The biggest effort I foresee is in mapping what I have to what the Soundgin has to make the same parameter control available, plus understanding how the Soundgin functions all fit together.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-11-22 05:14
    @Hippy

    Did you happen to do any more work on this project, or do you have additional examples
    of this code in use which you would be willing to share for learning?

    Thanks
    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
Sign In or Register to comment.