Shop OBEX P1 Docs P2 Docs Learn Events
My audio package (16bit, 4channel, sample based, w/sequencer) — Parallax Forums

My audio package (16bit, 4channel, sample based, w/sequencer)

XlogicXXlogicX Posts: 18
edited 2009-10-24 13:19 in Propeller 1
This is a 16-bit, 4-channel, sample based audio driver. It uses 3-cogs (not including the interpreted cog). I know this isn’t the first one out there; I enjoyed using Nick Sabalausky’s driver. However, I wanted something to call my own, and I wanted to add more features. The first feature that I created that makes this driver stand out is to be able to decrease the bit quality on the fly; such as going from 16-bit to 3-bit. This is also why I will never have a sample for a square wave, I just use any even duty sample and make it 1-bit <SPAN style="FONT-FAMILY: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: Wingdings"><SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">J

This is the first serious ASM code that I have written that wasn’t just flashing a light. So I’m sure I may have done some things in my code that look weird or stupid. To put it in perspective, I started 2 months ago not knowing how to pass more than one variable to a cog, not knowing about ctra, not understanding the concept of movs and movd in loops, and not yet grasping the propellers implementation of the object orientation. I had to completely re-write the program 2 times over. I would say 80-90% of my time was spent troubleshooting simple things that typos caused (those ones are less obvious than logical problems, to me). I’m happy to say that it works now, and I have overcome all of those things that I did not know. Also, I’m going to have to make a donation to the people that created GEAR if I can, I made heavy use out of that debugger/emulator.

The only part of the driver that I am completely finished with is the PCM engine; any added code to the main loop will lower the frequencies, and I don’t want to have to re-do the whole CON table of notes.

My next changes will probably be to the mixer engine (add more effects) and to add more wave samples.

I attached the driver, and a demo file (music2) that demonstrates a couple of its features (for version 2.0). I'll try to post updates as I do new Smile to it.

Edit: I'm sure not everyone will want to jump out of their seats and find their prop board with an audio setup to test this. Here are some links to the corresponding mp3 samples of said demo files:
(music2.spin)
www.phx2600.org/forum/download/file.php?id=11
(music_021.spin)
www.phx2600.org/forum/download/file.php?id=12

Driver currently in version 2.4

Post Edited (XlogicX) : 10/24/2009 1:21:49 PM GMT

Comments

  • XlogicXXlogicX Posts: 18
    edited 2009-10-17 13:59
    It wasn't my intent to post back so soon, but I updated to version 2.1. In this version, I added two effects to the mixer. I added a 'garble' effect, and an OR mask effect.

    I will update the original post with attachments of the new version, and another demo (music_021_demo.spin). This demonstrates these new effects, and it demonstrates the ability to use multiple channels (of which I forgot to demo on the last version).
  • XlogicXXlogicX Posts: 18
    edited 2009-10-17 17:10
    Added mp3's to original post.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-10-17 17:22
    re:Added mp3's to original post.

    Turn down your volume before you try them.

    burger.gif
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-10-17 17:33
    Great samples! Thanks for posting the MP3s!

    OBC

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

    Visit the: The Propeller Pages @ Warranty Void.
  • XlogicXXlogicX Posts: 18
    edited 2009-10-17 17:56
    @Bob Lawrence: Yeah, sorry about that, the levels on the mp3 are as high as they can get without clipping. What makes it worse is that the example mp3s aren't completely music to the ears, they are just demonstrations of some of the tricks that can be done.
  • KyeKye Posts: 2,200
    edited 2009-10-17 19:36
    Great work! I hoped you learned alot!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-10-17 20:16
    That's odd: I had turn to turn the volume almost all the way up to hear the MP3's (iTunes). Nonetheless, you've really managed to create some interesting sounds! Nicely done!

    -Phil
  • XlogicXXlogicX Posts: 18
    edited 2009-10-17 21:53
    @Phil: you actually helped me out a little, I made a couple of posts here and there, one of them being in the trick and traps. I thought I was having troubles with semaphores, you pointed out that it isn't really any issue with operating on 1 long at a time. This at least gave me to focus to stop looking at that 'problem' and look elsewhere. It turned out that it was an indexing problem, and I had a cog going rogue and eating my main program.
  • jazzedjazzed Posts: 11,803
    edited 2009-10-17 22:42
    Welcome to the Propeller forum. Congrats on your project. One question: Bass clef ?
  • hover1hover1 Posts: 1,929
    edited 2009-10-17 22:46
    Very nice driver, well done,

    But out of curiosity, why did you pick P31 as the Audio Out. That's normally reserved for programming and serial interface?

    P10 would have been a good choice for Demo Board users.

    Looking forward to updates.

    Jim
  • DelusDelus Posts: 79
    edited 2009-10-18 00:36
    Very impressive! I did something similar with one cog adding channels together and producing the actual output and another generating sine waves but it was abandoned when we decided to go with wav clips instead.
  • XlogicXXlogicX Posts: 18
    edited 2009-10-18 01:30
    @jazzed: I'm not sure what you want to know about the bass clef, but I am mostly interested in the lower range audio with the application I am going to eventually use this driver for.

    @hover1: Heh, I use Pin31 because I like to "hear" my chip get programmed [noparse]:)[/noparse], no really, this is the reason for it. You're reasoning for Pin10 makes sense, this is why I made the pin number a parameter for the PlayNote function. I actually had it hard coded for pin 31 up until recent versions of the driver, but I made it configurable just because that's better style. A lot of the newer changes I made to the program was mostly to make it usable for other people.
  • jazzedjazzed Posts: 11,803
    edited 2009-10-18 02:36
    I was just wondering about the significance of your hat. Enjoy your Propeller.
  • mirrormirror Posts: 322
    edited 2009-10-18 03:03
    XlogicX said...
    Also, I’m going to have to make a donation to the people that created GEAR if I can, I made heavy use out of that debugger/emulator.

    I haven't seen the original author of GEAR in many years, which is why I started working on it. I did some work on GEAR to try and improve the tool for others to use, and my belief is that any contribution you can make which enriches the Propeller community would be well appreciated.

    It's just a pity I've not had much time for "Propellering" lately, although I still keep an eye on the forum.
  • XlogicXXlogicX Posts: 18
    edited 2009-10-18 05:01
    @jazzed: I can't believe I missed the obvious, yeah, it's a bass clef. I'm big into music, but I think using the treble clef as an icon for music gets a little cliche. Being that I like the bass range more anyway, I use the bass clef (I play a 4-string).

    @mirror:That's really cool that you've contributed to GEAR. It's not often I use software where I'm not finding myself hoping for more features, GEAR had everything I could hope for in helping find mistakes that I made along the way.
  • XlogicXXlogicX Posts: 18
    edited 2009-10-21 10:02
    I just created version 2.2. Here are the notes from the change history:

    Ver 2.2 [noparse][[/noparse]10-21-2009]:
    •Added bass, tenor, alto, and soprano versions of noise wave
    •Added alto and soprano versions of sine wave
    •Added bass, tenor, alto, and soprano versions of square wave. I know, I know, I finally broke down and added these. I did
    this to support higher level functions like DownNote that don't take quality as a parameter.
    •Added DownNote function, documentation is included in function
    •Added UpNote function, documentation is included in function

    I included the new driver and it's corresponding demo file in the zip file in the original post.

    I will add an mp3 sample later today.
  • XlogicXXlogicX Posts: 18
    edited 2009-10-24 13:19
    I'm now at version 2.4. I updated the zip file in the first post. I only made some minor adjustments.

    I also included a sequencer program that uses my driver as an object, it gives the ability to play songs at a certain tempo based off of bar by bar note information in a DAT section. So I did the whole mario song this time. MP3 file is included, I tried to play with a couple of the new special effects I added to the driver, enjoy! (hopefully).
Sign In or Register to comment.