Shop OBEX P1 Docs P2 Docs Learn Events
Wav Audio Player — Parallax Forums

Wav Audio Player

RaymanRayman Posts: 14,646
edited 2020-04-19 19:03 in Propeller 2
After figuring out some smartpin stuff, was pretty easy to convert wav player to P2.

This example is set for A/V accessory board on P8 and the wav file copied to uSD card on eval board.

As before, .wav files have to be 16-bit PCM encoded

Uses @cheezus FSRW with inline assembly SPI driver. (Note: This part needs some work, you may or may not have to remove card momentarily between uses).

The binary is there or you can compile with FastSpin Version 4.1.4

Use a serial terminal at 115200 baud to see diagnostic info...

Comments

  • RaymanRayman Posts: 14,646
    I just added the wav player to the Mixed Signal Scope (in place of the DDS).

    Was a bit of a trick because only had one cog left and you really need two: One to full the buffers from SD and one to output to pins.
    Figured out a way to add the buffer filling job into the main idle process and it works OK with big buffers.

    But, I see a flaw and also one less than idea thing right away.

    The flaw is that the volume scales the output from 0V and not from 3.3/2 V. This limits the usefulness of my gain knob as it goes off scale when gain raised too much...

    The less than ideal thing is the stair stepped nature of the output. Would probably be better to do smooth transitions...
    4032 x 3024 - 3M
  • RaymanRayman Posts: 14,646
    edited 2020-04-25 20:54
    The above was using jumps to connect audio output pins to analog input pins.

    Got something unexpected when I changed analog channels to the actual audio output pins.
    Trying to figure what this is....

    If I right shift the analog data 6 places, I get something that might be the analog output (but small in amplitude).
    4032 x 3024 - 3M
  • RaymanRayman Posts: 14,646
    Docs say this about this DAC smartpin mode:
    If OUT is high, the ADC will be enabled and RDPIN/RQPIN can be used to retrieve the 16-bit ADC accumulation from the last sample period. This can be used to measure loading on the DAC pin.
    

    Must be what I'm seeing...
  • AribaAriba Posts: 2,690
    edited 2020-04-25 21:03
    Rayman wrote: »
    ...
    The flaw is that the volume scales the output from 0V and not from 3.3/2 V. This limits the usefulness of my gain knob as it goes off scale when gain raised too much...
    Yes. I've seen that before in your Audio player code. Try to do change your code from this:
                rdword  right,pData
                add     right,##$8000 
                and     right,##$FFFF
                mul     right,dRightVolume
                shr     right,#16           
    
    to this: (also for the left channel)
                rdword  right,pData
                muls    right,dRightVolume
                sar     right,#15           
                add     right,##$8000 
    
    The less than ideal thing is the stair stepped nature of the output. Would probably be better to do smooth transitions...
    I think the steps you see comes from the Scope ADC which has 5..6 bits resolution, not from the output with its 16 bit dithering.

    Andy


  • RaymanRayman Posts: 14,646
    edited 2020-04-25 21:02
    I think the staircase might be stepping at the sample rate of the wave data...
  • RaymanRayman Posts: 14,646
    Yeah, I used the cursors to measure width of steps and it is close to sample rate of 16 kHz...
    4032 x 3024 - 5M
  • RaymanRayman Posts: 14,646
    @Ariba Thanks! That works.

    Here’s a video of wav playing on scope
  • That is super cool Rayman

    Now you need to add a microphone input, and display of mic signal, for the full P2 karaoke experience
  • roglohrogloh Posts: 5,787
    edited 2020-04-27 07:29
    It's pretty good what you can do dynamically with tiles once you build up a drawing environment around them. Nice one. This setup could be a handy little tool when developing/testing out an I2S audio interface with its mixed signal sampling.
  • RaymanRayman Posts: 14,646
    edited 2020-04-28 18:03
    I'm curious as to why the output is so low in amplitude...

    I'm looking at input on pins 8 & 9 that is jumpered in from pins 14&15. So, there should be no loading.
    Have to go to 10X mode to get it to be close to full range on display.
    So, I guess output is only around 0.33 volts in amplitude...
  • AribaAriba Posts: 2,690
    With the volume multiply modification, the volume control range is now 0..$7FFF. A value near to 65535 will result in a negative small volume. Maybe that causes the low output?

    Andy
Sign In or Register to comment.