Shop OBEX P1 Docs P2 Docs Learn Events
16-bit PCM .wav file audio player — Parallax Forums

16-bit PCM .wav file audio player

Comments

  • RaymanRayman Posts: 14,744

    Tested with P2 Eval board with audio file on uSD card and A/V accessory on pin group P0..P7

  • RaymanRayman Posts: 14,744

    MP3 would be better if want to have audio files on flash, so good to have, thanks @pik33
    I think you have a player for other file types too, right?

  • RaymanRayman Posts: 14,744
    edited 2023-09-24 22:38

    Thanks to @JonnyMac , this version probably has a better txflush() routine in the serial driver (if I did it right).

  • Yes. That's the way Chip showed me how to read the TX pin busy flag -- and it solved an odd problem I was having with a project.

  • Wuerfel_21Wuerfel_21 Posts: 5,105
    edited 2023-09-24 23:04

    Speaking of different formats, I think I already posted this somewhere, but I've actually designed a custom codec that doesn't use much more resources than a straight wave player but compresses at 4.39 to 1 ratio (for 32kHz that comes out to ~232 kbit/s, which crucially is at most one 512 byte sector that has to be buffered per 60Hz video frame). https://github.com/Wuerfel21/Heptafon (check the propeller2 folder... also here's some sample files if you don't want to deal with the wonky C++ encoder)

    Though it's really optimized for P1 rather, on P2 you could spend more cycles and make use of fast multiply to get more quality out of the same bitrate.

  • pik33pik33 Posts: 2,384
    edited 2023-09-25 06:24

    @Rayman said:
    MP3 would be better if want to have audio files on flash, so good to have, thanks @pik33
    I think you have a player for other file types too, right?

    Yes, the repository that I linked, where this decoder code is, is the player repository. It is configured for P2-EC32 board, but can be adapted to work on anything that has an external ram that can be driven by rogloh's driver.

    Plays .wav, .mp3, .sid/.dmp, .mod and .spc and of course is still buggy but works. Now when Flexprop supports flash file system It can be updated to use flash too.

  • RaymanRayman Posts: 14,744

    Doing some testing today, trying to get this to work from flash instead of uSD.
    Think about have it.

    But, along the way, decided the signed math in the previous version wasn't quite right.
    Reverted to the unsigned math way from the original P1 version...
    Ver.2e in top post.

  • RaymanRayman Posts: 14,744
    edited 2023-10-12 20:58

    Just noticed that the cog is hardcoded to #2 in the previous posted examples...

    Seems I couldn't figure out why this didn't work:

                    org
                        cogatn  #1<<cog
                    end
    

    But, now I see you can do << with a register contents.
    Fixed like this now (hopefully):

        org
          mov     r,#1
          shl     r,cog                         
          cogatn  r
        end
    
  • RaymanRayman Posts: 14,744

    Just made a version that plays a wav file embedded in HUB RAM.
    Will put in top post...

  • instead of

        org
          mov     r,#1
          shl     r,cog                         
          cogatn  r
        end
    

    you want

        org
          decod   r,cog                         
          cogatn  r
        end
    
Sign In or Register to comment.