Shop OBEX P1 Docs P2 Docs Learn Events
P2 eval board, Audio module, Sound examples — Parallax Forums

P2 eval board, Audio module, Sound examples

Hi all!

I finally have the time to get into P2 programming, and the place I'd really like to start is audio programming. There are some audio demos in the object repo, and I have the audio expansion board that goes with the P2 eval board.

I wanted to try the reSound demos using the audio board, but I don't know which of the inputs I should plug the board into, or what to change in the source code to deal with whichever connector I've chosen. Is there some handy macro, or lookup able or something? How do you know which input to connect to?

The docs also don't talk about where the mod file needs to go - on the SD card I presume? In the root?

Any help would be greatly appreciated!

Comments

  • evanhevanh Posts: 15,126

    Please link/attach to webpage/files.

  • Ahle2Ahle2 Posts: 1,178

    Hi cfox,

    Try the simpleSound engine demos for something easy to just get going. It's called "simple" for a reason...

    1. Download "simpleSound(Beta2)_examples.zip" from https://forums.parallax.com/discussion/172894/simplesound-a-simple-to-use-sound-engine-for-the-p2/p1.
    2. Unzip
    3. Open up "main.spin2" from the "just_music" archive in Propeller Tool
    4. Change x and y to your physical pin numbers...
    CON
    
      _clkfreq     = 252_000_000
      LEFT_PIN     = x
      RIGHT_PIN    = y
    
    1. Change the module you want to play...
    music  file "theModYouWantToPlay.mod"
    
    1. Compile and run

    Notes:
    * clkfreq can be anything you like, the sound engine will automatically adapt to anything while trying to maximize the output mixing rate.
    * The module is loaded into the binary before downloading to the target.
    * Module + code can never exceed the 512k RAM limit on the P2

    /Johannes

  • So for the music file - where do I put that? On a SD card, or is it loaded through the propeller tool?

  • evanhevanh Posts: 15,126
    edited 2022-05-20 18:37

    Put it in the same directory as main.spin2. It gets compiled into the binary along with the code.

  • Ok - I followed your instructions> @Ahle2 said:

    Hi cfox,

    Hi Ahle2!

    Try the simpleSound engine demos for something easy to just get going. It's called "simple" for a reason...

    1. Download "simpleSound(Beta2)_examples.zip" from https://forums.parallax.com/discussion/172894/simplesound-a-simple-to-use-sound-engine-for-the-p2/p1.
    2. Unzip
    3. Open up "main.spin2" from the "just_music" archive in Propeller Tool
    4. Change x and y to your physical pin numbers...
    CON
    
      _clkfreq     = 252_000_000
      LEFT_PIN     = x
      RIGHT_PIN    = y
    

    Ok, did this. Now, one thing I'd like to make sure I have correct -- I attached the AV module to one of the sets of pins, the one marked "V3239", which seems to indicate the set of pins that it encompases.

    And according to the A/V module schematic I downloaded, the left pin (INL) is IO+8, and the right pin (INR) is IO+7, so I defined:
    LEFT_PIN = 32+8
    RIGHT_PIN = 32+7

    Also before I go on, at the bottom of the A/V schematic is an orange note saying: "Recommend: Always set VIO jumper to LDO on P2-EVAL when working with Audio!" -- except that I can't find any jumper labelled "VIO". There is a jumper labelled LDO VIN 5V that is current set. Is this the one it's talking about? Sorry if this is a supid question, but I just don't see anything else.

    1. Change the module you want to play...
    music  file "theModYouWantToPlay.mod"
    
    1. Compile and run

    Notes:
    * clkfreq can be anything you like, the sound engine will automatically adapt to anything while trying to maximize the output mixing rate.
    * The module is loaded into the binary before downloading to the target.
    * Module + code can never exceed the 512k RAM limit on the P2

    /Johannes

    I loaded the simpleSound(Beta2)_examples/simpleSound(beta)_example1_just_music/main.spin2 and RUN->Compile Current->Load RAM

    It compiled without error (currently set to play axel_f, which is fine), but I don't hear anything coming through the headphone port.

    Are my pin assumptions incorrect? Or is the VIO jumper thing the issue and I did it incorrectly? I don't even know how to debug the issue :(

    Thanks!

  • Part of the problem may be here:

    LEFT_PIN = 32+8
    RIGHT_PIN = 32+7

    Change that to l:

    LEFT_PIN = 32+7
    RIGHT_PIN = 32+6

    By my math, 32+8=40, which would be the first pin in the next pin group.

  • evanhevanh Posts: 15,126

    @cfox said:
    Also before I go on, at the bottom of the A/V schematic is an orange note saying: "Recommend: Always set VIO jumper to LDO on P2-EVAL when working with Audio!" -- except that I can't find any jumper labelled "VIO". There is a jumper labelled LDO VIN 5V that is current set. Is this the one it's talking about?

    You've got the correct jumper. That notice was for the RevA Eval Board - It had a two-position jumper for each group of eight I/O.

  • @JRoark said:
    Part of the problem may be here:

    LEFT_PIN = 32+8
    RIGHT_PIN = 32+7

    Change that to l:

    LEFT_PIN = 32+7
    RIGHT_PIN = 32+6

    By my math, 32+8=40, which would be the first pin in the next pin group.

    Yeah - when I zoomed into the diagram, what I took for a IO+8 clearly became an IO+6. My bad!

  • cfoxcfox Posts: 16
    edited 2022-05-23 15:23

    After the pin correction above, it's all working now! Fantastic! Thanks everyone!

    Just for the record - there were two problems. First problem was that I had the LEFT_PIN defined as 32+8 instead of 32+6, so it wouldn't have played. The right pin was correctly declared, but I also didn't have the headphone plug connected all the way in - I stopped at the first real resistance, but there was still one more "click" to go in engaging the other speaker. If I had pushed it all the way in before I would have heard music from at least one speaker, but because it wasn't all the way in, only one speaker was engaged, but that wasn't playing because of the pin problem. So I heard nothing at all.

    Anyway - now I feel much more comfortable about progressing. Thanks again!

Sign In or Register to comment.