Need help understanding audio

NGS, codecs, MeP, hardware JPEG, PNG, streaming, etc.
Post Reply
Baktillus
Posts: 3
Joined: Mon Jan 02, 2017 5:30 pm

Need help understanding audio

Post by Baktillus » Mon Jan 02, 2017 5:50 pm

Hey there,

I'm new here. I'm also new to C, so all this is exciting and confusing to me. Keep that in mind as we progress :D

I got my toolchain setup on bash in windows and deployed some of the examples. Then I started tinkering with the touch example (in VIM because I found the file location in windows way later :lol: ).
I basically copied over all relevant lines from the audio example and wanted to make the frequency dependent on the x coordinate of the first touch in the touches array.

Code is in a gist here: https://gist.github.com/anonymous/90a6d ... 2b64663985

Unfortunately no sound comes out of the speakers, while my own code seems to work (calculating a value between 0 and 48k from the SceTouchData.report.x)
I added some printf output to try and understand what values are being created where and why. What confused me was that wave_set() always returns the same value. So I don't really get how the buffer is used or rather what it contains, if its not information on the specific sound to be played next.

Any help would be appreciated since it was a lot of fun to tinker around with it.

xerpi
Posts: 4
Joined: Sun Jan 01, 2017 12:53 pm

Re: Need help understanding audio

Post by xerpi » Tue Jan 03, 2017 12:15 am

The only valid frequency values to pass to sceAudioOutOpenPort are:

Code: Select all

8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
(if you use SCE_AUDIO_OUT_PORT_TYPE_MAIN, the only valid value is 48000)

So if you want to use another frequency, you'll have to quantize it yourself.

EDIT: If you want to reconfigure the audio parameters after getting the audio port, you can use sceAudioOutSetConfig.

Baktillus
Posts: 3
Joined: Mon Jan 02, 2017 5:30 pm

Re: Need help understanding audio

Post by Baktillus » Tue Jan 03, 2017 11:11 am

Alright thanks, I should've paid more attention that..
So if you want to use another frequency, you'll have to quantize it yourself.
Can you point me in a direction with this? If sceAudioOutOpenPort is limited to these frequencies do I have to use external audiofiles, or maybe use an extra library?
Sorry if most of this is extremely basic, I just wanted to tinker around with audio generation to get into the SDK a bit.

xerpi
Posts: 4
Joined: Sun Jan 01, 2017 12:53 pm

Re: Need help understanding audio

Post by xerpi » Tue Jan 03, 2017 4:22 pm

If the audio output frequency is 48000Hz, and your sample's freq is 16000Hz for example, you'll have to repeat each of your samples 3 times (48000/16000 = 3).

Baktillus
Posts: 3
Joined: Mon Jan 02, 2017 5:30 pm

Re: Need help understanding audio

Post by Baktillus » Wed Jan 04, 2017 8:51 am

Much appreciated. Now the whole thing makes a lot more sense!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest