Jump to content
  • 0

How to use PCM audio


kliepatsch
 Share

Question

Hi everyone,

I am new to the X16, have been trying around a little. The next thing that I would like to get to work is the PCM audio. However, this turned out to not work for me. Could anyone help me with that?

I tried the following simple test (check if FIFO Full bit will be set eventually):

Quote

10 VPOKE 0,$9F3B,$8F : REM RESET, MAX VOLUME
20 VPOKE 0,$9F3C,0 : REM SET SAMPLE RATE TO ZERO
30 VPOKE 0,$9F3D,127 : REM WRITE DATA
40 A=VPEEK(0,$9F3B) AND 128 : REM CHECK IF BUFFER IS FULL
50 IF A=0 GOTO 20 : REM CONTINUE UNTIL BUFFER IS FULL
60 END

As recommended in the VERA documentation, I set the sample rate to zero in order for my data to not disappear while I am writing data into the FIFO.
The FIFO Full bit (which I am checking in line 40) seems to be set in line 10 by the reset command, and therefore the program exits immediately. If I leave line 10 away, the FIFO Full bit isn't set and the program gets stuck forever. But what I would expect is that the FIFO Full bit will be set only if the buffer is full.

Playback didn't work, either. (Edit: to check if playback works, I used a different test ... just wanted to mention it)

Thanks in advance.

Edited by kliepatsch
clarification
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
2 minutes ago, SlithyMatt said:

On closer look, you are mixing up CPU RAM and VRAM. The PCM registers are in the former, so replace your VPOKEs with regular POKEs. The PCM doesn't actually use VRAM at all, despite being built into the VERA. The 4kB buffer is built-in, and not externally addressible.

Thanks! That was it.

  • Like 1
Link to comment
Share on other sites

  • 0

Here's a minimal working example for PCM for anyone interested:

Quote

10 POKE $9F3B, $8F : REM RESET, MAX VOLUME
20 POKE $9F3C, 0 : REM ZERO SAMPLE RATE
30 FOR I=1 TO 4096
40 A%=INT(127*SIN(I*0.05))
50 IF A%<0 THEN A%=A%+256 : REM CONVERT TO 8 BIT SIGNED
60 POKE $9F3D, A%
70 NEXT I
80 POKE $9F3C, 128 : REM MAX SAMPLE RATE

It should compute for a while and eventually create a short sine wave beep.

Edited by kliepatsch
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use