Shop OBEX P1 Docs P2 Docs Learn Events
simpleSound - A simple to use sound engine for the P2 - Page 2 — Parallax Forums

simpleSound - A simple to use sound engine for the P2

24

Comments

  • I was excited to get simple WAV files to play; this is really fantastic, Johannes!

  • @pik33 said:
    I cannot get stereo separation to work: the module sounds the same, no matter what I put there, including 0

    I wonder if it is the connector on the A/V board. When testing my WAV player code I got both sides mixed in my headphones, but could see them clearly separated coming right out of the pins.

  • pik33pik33 Posts: 2,388

    There is a constant in the module player code, which should control stereo separation, but it doesnt work. The separation of module channels is always full, the constant doesn't work and I have to read the code to find why... or ask the author. I asked and then started to read the code... and then I had to go to sleep. To be continued as I want to learn P2 as fast as I can.

  • Ahle2Ahle2 Posts: 1,179

    @pik33

    I just tested to change the constant and it works.... must be something on your end!

    MUSIC_STEREO_SEPARATION = 32768 -> Full mono

    MUSIC_STEREO_SEPARATION = 0 -> Full stereo

    /Johannes

  • pik33pik33 Posts: 2,388
    edited 2021-02-10 14:48

    Now it works. Maybe I was too tired yesterday and made a mistake while messing with the code.

    Edit: What is wrong with this module?

  • Ahle2Ahle2 Posts: 1,179

    It's a Scream Tracker module! :lol:

    The file extension should be ".S3M". That is a totally differnet animal compared to Protracker. But of course, Fasttracker 2, Scream Tracker 3 or why not Digibooster Pro (I'm one of the few to knows about that one) replay routines could be made to incorporate into simpleSound.

  • Ahle2Ahle2 Posts: 1,179

    Here are some cool applications that are up for grabs...

    • A Protracker editor clone that outputs to HDMI, using USB mouse and keyboard as input devices
    • A Protracker player, with fullscreen oscilloscope view and a file selector that loads from SD card (and a star scroller in the background :smile:)
    • An Amiga cracktro clone

    Why not make a clone of this cool classic Cracktro?

    (The module is called "monday.mod" and can be found here: https://modarchive.org/index.php?request=search&query=random_voice_-_monday&submit=Find&search_type=filename_or_songtitle )

  • pik33pik33 Posts: 2,388

    I am studying now the P2 manuals.. I have to know how this P2 streamer works. Then I have an idea of a displaylist controlled video driver. Propplay - https://forums.parallax.com/discussion/140767/a-new-topic-for-vga-not-only-sid-player - has to be converted to P2.

  • evanhevanh Posts: 16,039
    edited 2021-02-11 00:10

    @pik33 said:
    I am studying now the P2 manuals.. I have to know how this P2 streamer works. Then I have an idea of a displaylist controlled video driver.

    First thing to know about is the command buffering hardware: There is the active command plus a pending command. And if a third XCONT/XZERO command is attempted with the buffer still pending then it will block until the buffer is free. Here's the actual documentation on it:

    Prop2 Ref Manual:
    There is a single-level command buffer in the streamer, enabling you to give it two initial commands before it makes you wait for the first command to finish before accepting another.

    Timing detail:

    The NCO frequency may also be set/changed via a 'SETQ D/#' instruction immediately preceding an XINIT/XZERO/XCONT instruction. When the streamer command executes, the new frequency will be set during the first clock of the command. If no SETQ is used before the instruction, the frequency will remain the same when the command executes.

    PS: Structurally, the streamer, alongside the LUT and FIFO, is part of a cog.

  • Ahle2Ahle2 Posts: 1,179
    edited 2021-02-11 09:52

    @Coley said:
    Brilliant!

    @Baggers said:
    This is awesome Ahle2 :D

    Thanks guys! When will you two come together and do something cool on the P2? You did some amazing stuff on the P1.

    @Rayman said:
    Example uses a fair amount of memory, 140 kB. But, 109 kB of that looks like the embedded music and sound files.

    The complete sound engine takes just 11 kB compiled in Propeller Tool, while samples and music usually takes up from tens of kB to hundreds of kB depending on quality and number of assets.

  • Ahle2Ahle2 Posts: 1,179

    @JonnyMac said:
    I was excited to get simple WAV files to play; this is really fantastic, Johannes!

    Thanks JonnyMac! :smile:
    A wav player is the first step to do something like this. A Protracker module is made up of a number of samples (kind of like many .wav files stored in RAM but in raw format without headers). The music data is a description of how these samples should be "cut--n-pasted together" over time using different pitches and gains + effects like vibrato, tremolo, pitchbends and sample looping to produce the music. It is realtime mixed using the reSound driver as the back end. reSound allows you to have up to a total of 64 samples mixed togheter with different pitches, gains and panning at the same time. That way you could easily just assign some extra channels for playback of sound effects while the music is playing.

    (Btw, open up any of my examples as a compiled P2 binary in your favourite sound editor using raw unsigned 8 bits and you can hear all the instrument samples)

  • ColeyColey Posts: 1,110
    edited 2021-02-11 18:31

    @Ahle2 said:
    Thanks guys! When will you two come together and do something cool on the P2? You did some amazing stuff on the P1.

    We are already working on a couple of projects together, watch this space ;-)

    If you have the time you should really come on the Zoom meeting open discussion that are held every other Tuesday, there's some really great projects underway.
    Ken did say he may be able to arrange one a bit earlier in the day to help us over in the UK and Europe.
    The community seems to be buzzing again. :smile:

  • @cgracey said:
    Ahle, any chance you could make a YouTube video just to demonstrate the sound capability? I mean, something one could just click on to get an idea of what we're talking about here?

    It doesn't have to explain anything, but just give a sound sample.

    I think the sound quality would be very good, way beyond people's normal 8-bit expectations.

    I'm working in that direction at this moment.

    Ken Gracey

  • cgraceycgracey Posts: 14,208
    edited 2021-02-11 20:06

    @Ahle2 said:
    Latest release - Beta 2

    Whoa!!!!

    I just tried this out. It sounds at least as good as my PC sound card.

    Good job, Ahle2!

  • cgraceycgracey Posts: 14,208

    Ahle2, how is this music stored? Is it being synthesized or are recordings being played at various pitches?

    With good headphones, I think I'm hearing when channels are being added in and taken out. I seem to be hearing slight steps in the signal that is coincident with sounds starting and ending. That's a minor imperfection that I'm sure can be addressed. I couldn't tell this with my desktop speakers, but the headphones revealed more details.

    This is pretty amazing. The sound is very dynamic. I am super happy about this! I was hoping the DACs would be suitable for this kind of thing. Those quiet 3.3V LDO's are an important ingredient in making this work well.

  • ColeyColey Posts: 1,110

    @cgracey said:

    @Ahle2 said:
    Latest release - Beta 2

    Whoa!!!!

    I just tried this out. It sounds at least as good as my PC sound card.

    Good job, Ahle2!

    Chip, try this mod file, it sounds great with simpleSound

  • cgraceycgracey Posts: 14,208
    edited 2021-02-11 22:06

    @Coley said:

    @cgracey said:

    @Ahle2 said:
    Latest release - Beta 2

    Whoa!!!!

    I just tried this out. It sounds at least as good as my PC sound card.

    Good job, Ahle2!

    Chip, try this mod file, it sounds great with simpleSound

    Thanks, Coley. That sounds pretty good.

    I read about the MOD file format here:

    https://en.wikipedia.org/wiki/MOD_(file_format)

    Do you know if pitch (play rate) can be selected for each sub-recording? They sure get a lot of play time out of these data sets.

  • evanhevanh Posts: 16,039
    edited 2021-02-11 23:15

    Yes, in hardware terms, each of the four tracks of the mod format can independently set the sample rates at each step in the patterns. It's based on how the Amiga hardware works - Which is four DMA channels feeding four DACs. No mixing in software. Very handy for games and demos.
    PS: Mixing to stereo was done analogue.

  • evanhevanh Posts: 16,039

    Max sample rate were a tad low though. Aliasing was a given. Sometimes it added effect but mostly just invasive. The Amiga 1000 came with a fixed 4 kHz low pass filter which put a notable dulling effect. In later models it was switchable.

  • Ken GraceyKen Gracey Posts: 7,395
    edited 2021-02-12 02:55

    Wow, wow! The quality is well beyond what I expected.

    This will make a really nice Quick Byte. I'm trying to add a menu system to the example where the user can select songs from a menu (I'll pick a number of them that fit the memory). I need some help with the coding because the sound.PollTick() method isn't called frequently. What's the best way to structure the program? Maye a serial timeout - if no key is pressed then leave the case statement?

    Thanks! Ken

    Ken Gracey

  • Is there a YouTube of this yet?
    RJ

  • Ahle2Ahle2 Posts: 1,179
    edited 2021-02-12 08:03

    @cgracey said:
    Ahle2, how is this music stored? Is it being synthesized or are recordings being played at various pitches?

    With good headphones, I think I'm hearing when channels are being added in and taken out. I seem to be hearing slight steps in the signal that is coincident with sounds starting and ending. That's a minor imperfection that I'm sure can be addressed. I couldn't tell this with my desktop speakers, but the headphones revealed more details.

    This is pretty amazing. The sound is very dynamic. I am super happy about this! I was hoping the DACs would be suitable for this kind of thing. Those quiet 3.3V LDO's are an important ingredient in making this work well.

    @cgracey said:
    Do you know if pitch (play rate) can be selected for each sub-recording? They sure get a lot of play time out of these data sets.

    I qoute myself from some posts above...

    @JonnyMac said:
    I was excited to get simple WAV files to play; this is really fantastic, Johannes!

    Thanks JonnyMac! :smile:
    A wav player is the first step to do something like this. A Protracker module is made up of a number of samples (kind of like many .wav files stored in RAM but in raw format without headers). The music data is a description of how these samples should be "cut--n-pasted together" over time using different pitches and gains + effects like vibrato, tremolo, pitchbends and sample looping to produce the music. It is realtime mixed using the reSound driver as the back end. reSound allows you to have up to a total of 64 samples mixed togheter with different pitches, gains and panning at the same time. That way you could easily just assign some extra channels for playback of sound effects while the music is playing.

    I loved being a Commodore Amiga user back in the day. This kind of sound was amazing in the 80's when PC's had that PC speaker thingy and other machines had square wave PSG's. The only other computer with cool sound hardware was the Commodore 64 with a proper syntehsizer onboard. In theory the Amiga sound output in the 80's was this quality or even better as it had 4 completely independant DAC's with separate frequency and volume controls running at ~3.5 MHz; But in reality, thanks to 80's electronics, the sound got a little bit colored. I still have got my original Amiga 500 + 4 other later purchases in my collection. I couldn't help myself to not modifiy one of the machines analog circuitry just after the Paula (sound chip) with modern components, capacitors, etc. It sounds noticeable better.

    Here is a clip from a 1989 Amiga game that was one of the first I ran when I just got the computer. I was floored...

  • Ahle2Ahle2 Posts: 1,179

    @"Ken Gracey"

    You could make use of an timer interrupt routine to call that pollTick() method independantly from your main loop, I'm not sure if that will break the other objects though?! Othwerwise, you could just start another thread/cog to handle it.

    Also, the "sound.start(LEFT_PIN, RIGHT_PIN)" should only be called once as an initializer for the sound engine at the very top.

  • Ahle2Ahle2 Posts: 1,179

    @RetroJeff said:
    Is there a YouTube of this yet?
    RJ

    Not yet... I will hopefully get some spare time this weekend to post something.

  • Ahle2Ahle2 Posts: 1,179
    edited 2021-02-12 08:44

    @"Ken Gracey"

    Is there a non blocking version of that rx method? Then you could get this to work... Also, then you would have to clear the screen and print the menu just once and not every main loop iteration.

    Edit: Thinking about it some more, this could be a great way to introduce the concept of interrupts to the users. Just make a timer interrupt routine that is called at 50 Hz and call the tick() method. (not the pollTick method)

  • Ahle2Ahle2 Posts: 1,179

    @evanh said:
    Max sample rate were a tad low though. Aliasing was a given. Sometimes it added effect but mostly just invasive. The Amiga 1000 came with a fixed 4 kHz low pass filter which put a notable dulling effect. In later models it was switchable.

    Yes, the maximum sample rate per channel is ~28 kHz for normal PAL/NTSC Amigas (OCS) due to how the DMA system works. Later models with ECS and AGA chip sets could handle up to 56 kHz per sound channel in "VGA" mode or some other modes that had an above 15 kHz horizontal refresh rate. (Wow the Amiga hardware was so flexible, Jay Miner really had a way of thnking outside the box) But the thing that most people don't understand is that the samples are not downmixed in anyway, not in the frequency domain, nor in the volume domain. So no additional aliasing or quantizing noise are introduced. If the instrument samples are sampled at a multiple of the the instrument period, the aliasing overtones will be harmonic and actually add to the fidelity (note, not HIGH fidelity). That's the reason why modules played on the Amiga always sounded great while the first DOS module players using 8 bit sound blaster hardware on the PC sounded awful. The aliasing went over the roof and the quantizing noise was horrible. And not to mention the poor PC doing everything in software had no CPU cycles left to do anything but showing a static background.

  • evanhevanh Posts: 16,039

    I was certainly in awe of some of the artists that put those modules together. They were far better than anything in the music charts. I am a melody type though. Lyrics don't do it for me.

  • CJMJCJMJ Posts: 226
    edited 2021-02-12 15:35

    I was reading the description as to how the Protracker modules work. IIRC... This is similar to how the audio subsystem onboard the ISS works. The internal audio subsystem sends small packets of audio to an S-band subsystem pre-processor which compares the small waveforms against its library and then transmits an appropriate ID to the ground which is then looked up in a library in the post-processor which "recreates" the audio. That's why we get dropouts from certain astronauts. Their vocal patterns don't match anything in the pre-processor's library. It's the same reason why wakeup music transmitted to the ISS [and Shuttle] always sounds so crappy (i.e. the library was created for the range of the human voice). That's also why the audio coming down via the laptops (using internet based technologies) sounds so much better.

  • Ken GraceyKen Gracey Posts: 7,395
    edited 2021-02-12 22:27

    For those who requested a video, here's one (with the program I've attached):

    Keep the audio system in mind as you listen to this: A/V board to a dirty cheap $5 portable hamburger speaker, picked up by my Logitech headset microphone, and then put on YouTube.

    Ken Gracey

  • I have not tried your examples yet Ahle2 - But would it be possible to record individual words and play them back in a sequence to make (simple) spoken sentences?

Sign In or Register to comment.