forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

we can use "sceAudioSetFrequency" to change AudioF

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
cooleyes



Joined: 18 May 2006
Posts: 125

PostPosted: Thu Jun 07, 2007 3:14 pm    Post subject: we can use "sceAudioSetFrequency" to change AudioF Reply with quote

as we all know, we can use sceAudioOutputBlocking to play 16bit PCM data.

but all homebrew just support 44100Hz samplerate.

I browse moonlight's "PSP PRX Libraries Documentation Project",

and find out a function "sceAudioSetFrequency" in audio.prx , sceAudio_driver lib.

it can change the audio device's Frequency.

SceInt32 sceAudioSetFrequency(SceInt32 frequency); //frequency=44100 or 48000, if success it will return 0

it can setFrequency to 44100Hz or 48000Hz

sceAudio_driver.S
Code:

   .set noreorder

#include "pspimport.s"

#ifdef F_sceAudio_driver_0000
   IMPORT_START   "sceAudio_driver",0x00010000
#endif

#ifdef F_sceAudio_driver_0001
   IMPORT_FUNC   "sceAudio_driver",0x80F1F7E0,sceAudioInit
#endif

#ifdef F_sceAudio_driver_0002
   IMPORT_FUNC   "sceAudio_driver",0x210567F7,sceAudioEnd
#endif

#ifdef F_sceAudio_driver_0003
   IMPORT_FUNC   "sceAudio_driver",0xA2BEAA6C,sceAudioSetFrequency
#endif

#ifdef F_sceAudio_driver_0004
   IMPORT_FUNC   "sceAudio_driver",0xB61595C0,sceAudioLoopbackTest
#endif

#ifdef F_sceAudio_driver_0005
   IMPORT_FUNC   "sceAudio_driver",0x927AC32B,sceAudioSetVolumeOffset
#endif

#ifdef F_sceAudio_driver_0006
   IMPORT_FUNC   "sceAudio_driver",0x8C1009B2,sceAudioOutput
#endif

#ifdef F_sceAudio_driver_0007
   IMPORT_FUNC   "sceAudio_driver",0x136CAF51,sceAudioOutputBlocking
#endif

#ifdef F_sceAudio_driver_0008
   IMPORT_FUNC   "sceAudio_driver",0xE2D56B2D,sceAudioOutputPanned
#endif

#ifdef F_sceAudio_driver_0009
   IMPORT_FUNC   "sceAudio_driver",0x13F592BC,sceAudioOutputPannedBlocking
#endif

#ifdef F_sceAudio_driver_0010
   IMPORT_FUNC   "sceAudio_driver",0x5EC81C55,sceAudioChReserve
#endif

#ifdef F_sceAudio_driver_0011
   IMPORT_FUNC   "sceAudio_driver",0x41EFADE7,sceAudioOneshotOutput
#endif

#ifdef F_sceAudio_driver_0012
   IMPORT_FUNC   "sceAudio_driver",0x6FC46853,sceAudioChRelease
#endif

#ifdef F_sceAudio_driver_0013
   IMPORT_FUNC   "sceAudio_driver",0xB011922F,sceAudio_driver_B011922F
#endif

#ifdef F_sceAudio_driver_0014
   IMPORT_FUNC   "sceAudio_driver",0xCB2E439E,sceAudioSetChannelDataLen
#endif

#ifdef F_sceAudio_driver_0015
   IMPORT_FUNC   "sceAudio_driver",0x95FD0C2D,sceAudioChangeChannelConfig
#endif

#ifdef F_sceAudio_driver_0016
   IMPORT_FUNC   "sceAudio_driver",0xB7E1D8E7,sceAudioChangeChannelVolume
#endif

#ifdef F_sceAudio_driver_0017
   IMPORT_FUNC   "sceAudio_driver",0x38553111,sceAudio_driver_38553111
#endif

#ifdef F_sceAudio_driver_0018
   IMPORT_FUNC   "sceAudio_driver",0x5C37C0AE,sceAudio_driver_5C37C0AE
#endif

#ifdef F_sceAudio_driver_0019
   IMPORT_FUNC   "sceAudio_driver",0xE0727056,sceAudio_driver_E0727056
#endif

#ifdef F_sceAudio_driver_0020
   IMPORT_FUNC   "sceAudio_driver",0x086E5895,sceAudioInputBlocking
#endif

#ifdef F_sceAudio_driver_0021
   IMPORT_FUNC   "sceAudio_driver",0x6D4BEC68,sceAudioInput
#endif

#ifdef F_sceAudio_driver_0022
   IMPORT_FUNC   "sceAudio_driver",0xA708C6A6,sceAudioGetInputLength
#endif

#ifdef F_sceAudio_driver_0023
   IMPORT_FUNC   "sceAudio_driver",0x87B2E651,sceAudioWaitInputEnd
#endif

#ifdef F_sceAudio_driver_0024
   IMPORT_FUNC   "sceAudio_driver",0x7DE61688,sceAudioInputInit
#endif

#ifdef F_sceAudio_driver_0025
   IMPORT_FUNC   "sceAudio_driver",0xE926D3FB,sceAudioInputInitEx
#endif

#ifdef F_sceAudio_driver_0026
   IMPORT_FUNC   "sceAudio_driver",0xA633048E,sceAudioPollInputEnd
#endif

#ifdef F_sceAudio_driver_0027
   IMPORT_FUNC   "sceAudio_driver",0xE9D97901,sceAudioGetChannelRestLen
#endif


pspaudiodriver.h
Code:

/*
 * pspaudiodriver.h - Prototypes for the sceAudio_driver library.
 *
 * Copyright (c) 2007 cooleyes <eyes.cooleyes@gmail.com>
 */
#ifndef __SCEAUDIODRIVER_H__
#define __SCEAUDIODRIVER_H__

#include <psptypes.h>

#ifdef __cplusplus
extern "C" {
#endif

SceInt32 sceAudioSetFrequency(SceInt32 frequency);

#ifdef __cplusplus
}
#endif
Back to top
View user's profile Send private message
SilverSpring



Joined: 27 Feb 2007
Posts: 115

PostPosted: Thu Jun 07, 2007 3:35 pm    Post subject: Reply with quote

int sceClockgenAudioClkSetFreq(int freq); // freq can be 44100 or 48000

Dont know if same outcome??

EDIT:

Ok, I just checked, sceAudioSetFrequency passes freq to sceClockgenAudioClkSetFreq to set the freq, but it also passes freq to sceCodecSetFrequency as well.
Back to top
View user's profile Send private message Visit poster's website
Mihawk



Joined: 03 Apr 2007
Posts: 29

PostPosted: Thu Jun 07, 2007 9:29 pm    Post subject: Reply with quote

Nice, could be usefull.
But is it not possible to use lower frequencies, like 22.05 or 24kHz? or are only those two (44.1 and 48kHz) valid?
Back to top
View user's profile Send private message
SilverSpring



Joined: 27 Feb 2007
Posts: 115

PostPosted: Thu Jun 07, 2007 10:08 pm    Post subject: Reply with quote

The function only accepts 44100 and 48000, gives error otherwise.
Back to top
View user's profile Send private message Visit poster's website
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Fri Jun 08, 2007 12:01 am    Post subject: Reply with quote

wonderful !! so 48kHz OGG playback is now possible :)
thanx to you cooleyes keep it up !
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Fri Jun 08, 2007 3:32 am    Post subject: Reply with quote

Smaller frequencys can easily be done by simple sample doubling/quadrupling.
Nice find there cooleyes :)
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri Jun 08, 2007 5:10 am    Post subject: Reply with quote

There are plenty of rate resamplers out there. The trick is making it sound as good as possible without using too much CPU time. The code can be found everywhere because the vast majority of PC sound cards use fix rate playback (the most common being 48KHz).
Back to top
View user's profile Send private message AIM Address
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Fri Jun 08, 2007 6:31 pm    Post subject: Reply with quote

But you don't need any heavy math for getting 22.050/11.025 or 24.000/12.000Hz when you can playback 44100 and 48000 on hardware.
You just need to double/quadruple every single sample and you're done.
The big problem with playing 48000 or multiples Hz data, requiring fancy sample rate converting was only until now.
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Sat Jun 09, 2007 1:54 am    Post subject: Reply with quote

Quote:
But you don't need any heavy math for getting 22.050/11.025 or 24.000/12.000Hz when you can playback 44100 and 48000 on hardware.
You just need to double/quadruple every single sample and you're done.
Unless you care about the resulting signal quality :)
Doing a zero-order hold like this will result in some pretty bad aliasing artifacts. A first-order hold (linear interpolation) would be a little better. Really, using something like libsamplerate would make more sense.
Back to top
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Sat May 03, 2008 11:03 pm    Post subject: Reply with quote

Hi, does someone know the correct nid for the 3.90 firmware?

I think it might be one of this (return 0), but i can't play a custom 48khz mp3 :

//IMPORT_FUNC "sceAudio_driver",0x2533CE02,sceAudioSetFrequency // Do not seems
//IMPORT_FUNC "sceAudio_driver",0x9A34BC0D,sceAudioSetFrequency
//IMPORT_FUNC "sceAudio_driver",0xA1B19554,sceAudioSetFrequency
//IMPORT_FUNC "sceAudio_driver",0xA8B12BF0,sceAudioSetFrequency
//IMPORT_FUNC "sceAudio_driver",0xD5CE71B8,sceAudioSetFrequency // Do not seems
Back to top
View user's profile Send private message
cooleyes



Joined: 18 May 2006
Posts: 125

PostPosted: Sun May 04, 2008 12:43 am    Post subject: Reply with quote

Cpasjuste wrote:
Hi, does someone know the correct nid for the 3.90 firmware?

I think it might be one of this (return 0), but i can't play a custom 48khz mp3 :

//IMPORT_FUNC "sceAudio_driver",0x2533CE02,sceAudioSetFrequency // Do not seems
//IMPORT_FUNC "sceAudio_driver",0x9A34BC0D,sceAudioSetFrequency
//IMPORT_FUNC "sceAudio_driver",0xA1B19554,sceAudioSetFrequency
//IMPORT_FUNC "sceAudio_driver",0xA8B12BF0,sceAudioSetFrequency
//IMPORT_FUNC "sceAudio_driver",0xD5CE71B8,sceAudioSetFrequency // Do not seems


Code:

   .set noreorder

#include "pspimport.s"

   IMPORT_START   "sceAudio_driver",0x00010000
   IMPORT_FUNC   "sceAudio_driver",0x442588EB,sceAudioSetFrequency371
   IMPORT_FUNC   "sceAudio_driver",0x9A34BC0D,sceAudioSetFrequency380
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun May 04, 2008 4:59 am    Post subject: Reply with quote

You should probably use the old value and rely on the NID resolver. Remember that this is a kernel-level call and should be put into an external kernel-mode prx to be called from the user app. There's a thread on doing stuff like that, or you can look at the code for PMP Player Advance.

Don't forget that your user-mode app must also be a PRX (set BUILD_PRX in the makefile) to load a kernel-mode external prx lib.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group