PAlib는 2가지 다른 소리 출력 방법을 제공한다.
wav 를 재생하는 것 같은, raw 포맷은 특수 효과(레이저 소리 등)에 좋다. 하지만 음악을 위해 너무 많은 공간이 필요하다.
mod player 는 음악을 재생하는데 효과적이다. 각각의 음악이 롬에서 매우 적은 공간을 차지하기 때문이다.
-. Raw 사운드 파일
DS는 wav 파일을(또는 mp3, ogg같은 다른 포맷) 재생할수 없다. 그래서 raw 포맷으로 파일을 변환하고 재생해야 한다.
Wav 를 Raw로 변환하기
변환툴로는 Switch, Audacity, Sox(커맨드라인 사용) 이 있지만 여기서는 Switch를 사용할 것이다.
Switch를 위에 링크에서 다운받아 설치하여 열어 보자.
Add File 이나 Add Folder 버튼을 클릭하여 변환할 리스트 파일을 더한다. 변환할 모든 파일을 추가한 후 Output Format(바닥 왼쪽)을 .raw 포맷으로 변경한다. 그리고 Encoder Settings 를 다음과 같이 한다.

선호한다면 스테레오 출력으로 놔둘수 있다. 또한 샘플링을 11025 과 다른 걸로 설정 할 수 있다. 하지만 변환한 파일이 잘 작동하기 위해서는 포맷은 8 bit signed 로 설정해야 한다. 이 옵션은 적당한 음질로 작은 파일을 생성할 수 있다.
Output Folder를 설정한다. 이제 준비가 되었으면 Convert 버튼을 클릭한다. .raw 파일이 몇초만에 생성 될것이다.
Raw 파일 재생
raw 파일이 생성되었으면 프로젝트의 data 디렉토리에 놓는다. Sound/Sound 예제이다.
2. PA_InitSound(); 는 소리를 초기화 한다. 사용하지 않으면 modplayer는 작동하지 않는다.
3. PA_PlayMod(modfile); 주어진 modfile를 재생한다.
마지막으로 제한은 mod 파일은 1-16 채널을 가질수 있는데.. 8 채널만 사용하기 권장한다. 나머지 8 채널은 음향 효과를 위해 남겨둔다.
wav 를 재생하는 것 같은, raw 포맷은 특수 효과(레이저 소리 등)에 좋다. 하지만 음악을 위해 너무 많은 공간이 필요하다.
mod player 는 음악을 재생하는데 효과적이다. 각각의 음악이 롬에서 매우 적은 공간을 차지하기 때문이다.
-. Raw 사운드 파일
DS는 wav 파일을(또는 mp3, ogg같은 다른 포맷) 재생할수 없다. 그래서 raw 포맷으로 파일을 변환하고 재생해야 한다.
Wav 를 Raw로 변환하기
변환툴로는 Switch, Audacity, Sox(커맨드라인 사용) 이 있지만 여기서는 Switch를 사용할 것이다.
Switch를 위에 링크에서 다운받아 설치하여 열어 보자.


선호한다면 스테레오 출력으로 놔둘수 있다. 또한 샘플링을 11025 과 다른 걸로 설정 할 수 있다. 하지만 변환한 파일이 잘 작동하기 위해서는 포맷은 8 bit signed 로 설정해야 한다. 이 옵션은 적당한 음질로 작은 파일을 생성할 수 있다.
Output Folder를 설정한다. 이제 준비가 되었으면 Convert 버튼을 클릭한다. .raw 파일이 몇초만에 생성 될것이다.
Raw 파일 재생
raw 파일이 생성되었으면 프로젝트의 data 디렉토리에 놓는다. Sound/Sound 예제이다.
#include <PA9.h> // Include for PA_Lib
#include "saberoff.h" // Include the sound (found in the data folder in .raw format - for saberoff.raw use saberoff.h)
// Function: main()
int main(int argc, char ** argv)
{
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
PA_InitText(0, 0);
PA_InitSound(); // Init the sound system
PA_OutputSimpleText(0, 6, 10, "Press A to play the sound");
// Infinite loop to keep the program running
while (1)
{ // Play the sound if A is pressed...
if (Pad.Newpress.A) PA_PlaySimpleSound(0, saberoff);//here, too. Only saberoff
PA_WaitForVBL();
}
return 1;
}
#include "saberoff.h" // Include the sound (found in the data folder in .raw format - for saberoff.raw use saberoff.h)
// Function: main()
int main(int argc, char ** argv)
{
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
PA_InitText(0, 0);
PA_InitSound(); // Init the sound system
PA_OutputSimpleText(0, 6, 10, "Press A to play the sound");
// Infinite loop to keep the program running
while (1)
{ // Play the sound if A is pressed...
if (Pad.Newpress.A) PA_PlaySimpleSound(0, saberoff);//here, too. Only saberoff
PA_WaitForVBL();
}
return 1;
}
1. #include "saberoff_raw.h" 는 raw 파일을 포함한다. 단지 PAlib를 포함한 후 nameoftherawfile.h 형식으로 놓으면 된다.
2. PA_InitSound(); 는 PAlib의 사운드 시스템을 (raw, mod 파일 양쪽다) 초기화한다. 기본 raw 파일을 11025 샘플율과 8 bit signed 포맷으로 설정한다.
3. PA_PlaySimpleSound(channel, soundfile); 이것은 channel (0-7) 과 사운드 파일을 고르면 끝이다. 동시에 8개 채널까지 재생이 가능하다.(기본적으로 8개 나머지 유용한 채널은 mod player에 예약되어 있다. 하지만 이것도 나중에 변경 할수 있다.)
-. Mod 파일
Mod 파일은 사용하기 좋다. 쉽고 매우 작은 공간을 롬에서 차지한다. 소리도 꽤 좋은 편이다. 하지만 생성하기가 그리 쉽지는 않다. The Mod Archive, Exotica , ModLand 의 자료를 사용해보기 바란다.
Sound/ModPlayer 예제이다. 먼저 mod 파일을 data 디렉토리에 놓는다. 파일이 없으면 생성하라.
// Includes
#include <PA9.h> // Include for PA_Lib
#include "modfile.h" // Include the mod file (the .mod file is in the data directory)
// Function: main()
int main(int argc, char ** argv){
PA_Init(); // PA Init...
PA_InitVBL(); // VBL Init...
PA_InitSound(); // Sound Init, for the mod player...
PA_PlayMod(modfile_mod); // Play a given mod
while(1){ // Infinite loop
PA_WaitForVBL();
}
return 0;
} // End of main()
1. #include "modfile.h" 은 파일의 상위에 놓는데 PAlib를 포함하고 난 바로 다음이다. 이 파일은 modfile name + .h 이다. 만일 추가하지 않으면 프로그램은 modfile 이 어디 있는지 알지 못한다.#include <PA9.h> // Include for PA_Lib
#include "modfile.h" // Include the mod file (the .mod file is in the data directory)
// Function: main()
int main(int argc, char ** argv){
PA_Init(); // PA Init...
PA_InitVBL(); // VBL Init...
PA_InitSound(); // Sound Init, for the mod player...
PA_PlayMod(modfile_mod); // Play a given mod
while(1){ // Infinite loop
PA_WaitForVBL();
}
return 0;
} // End of main()
2. PA_InitSound(); 는 소리를 초기화 한다. 사용하지 않으면 modplayer는 작동하지 않는다.
3. PA_PlayMod(modfile); 주어진 modfile를 재생한다.
마지막으로 제한은 mod 파일은 1-16 채널을 가질수 있는데.. 8 채널만 사용하기 권장한다. 나머지 8 채널은 음향 효과를 위해 남겨둔다.
