ゲームサウンド部。といっても発声のみですが。
初音ミクさんにも参加して頂く予定です。
main.c
/*-------------------------------------------------------------------- voice module test version 0.01 Jan 21, 2010 By. REGEKATSU --------------------------------------------------------------------*/ #include <stdio.h> #include <nds/ndstypes.h> #include <nds/interrupts.h> #include <nds/arm9/input.h> #include <nds/arm9/console.h> #include "Voice.h" //--------------------------------------------------------------------------------- int main(void){ //--------------------------------------------------------------------------------- VOICE_CV cv = VOICE_ORG; consoleDemoInit(); printf("\x01b[0;0Hvoice module test\n\nversion 0.01\nJan 21, 2010\n\nBy. REGEKATSU\n\n\n"); Voice_Init(); while(1) { swiWaitForVBlank(); scanKeys(); //change cv if(keysDown() & KEY_A){ if(cv != VOICE_ORG){ cv = VOICE_ORG; printf("CV_ORG\n"); }else{ cv = VOICE_MIKU; printf("CV_MIKU\n"); } } //play dialog if(keysDown() & KEY_LEFT){ Voice_Play(cv, VOICE_JANKEN); printf("DIALOG_JANKEN\n"); } if(keysDown() & KEY_RIGHT){ Voice_Play(cv, VOICE_AIKODE); printf("DIALOG_AIKODE\n"); } if(keysDown() & KEY_UP){ Voice_Play(cv, VOICE_PONG); printf("DIALOG_PONG\n"); } if(keysDown() & KEY_DOWN){ Voice_Play(cv, VOICE_SHO); printf("DIALOG_SHO\n"); } if(keysDown() & KEY_START){ Voice_Play(cv, VOICE_YATTANE); printf("DIALOG_YATTANE\n"); } if(keysDown() & KEY_SELECT){ Voice_Play(cv, VOICE_ZUKO); printf("DIALOG_ZUKO\n"); } } } //---------------------------------------------------------------------------------
Voice.h
/*--------------------------------------------------------------------------------- voice module header version 0.01 Jan 21, 2010 By. REGEKATSU ---------------------------------------------------------------------------------*/ #ifndef _VOICE_H_ #define _VOICE_H_ typedef enum{ VOICE_ORG, VOICE_MIKU }VOICE_CV; #define VOICE_CV_MAX 2 typedef enum{ VOICE_JANKEN, VOICE_AIKODE, VOICE_PONG, VOICE_SHO, VOICE_YATTANE, VOICE_ZUKO }VOICE_DIALOG; #define VOICE_DIALOG_MAX 6 #ifdef __cplusplus extern "C" { #endif void Voice_Init(void); void Voice_Play(VOICE_CV cv, VOICE_DIALOG dialog); void Voice_Stop(void); #ifdef __cplusplus } #endif #endif //_VOICE_H_
Voice.c
/*--------------------------------------------------------------------------------- voice module routine version 0.01 Jan 21, 2010 By. REGEKATSU ---------------------------------------------------------------------------------*/ #include <string.h> #include <nds/arm9/sound.h> #include "Voice.h" //VOICE_CV_ORG #include "voice_org_janken_raw.h" #include "voice_org_pong_raw.h" #include "voice_org_aikode_raw.h" #include "voice_org_sho_raw.h" #include "voice_org_yattane_raw.h" #include "voice_org_zuko_raw.h" //VOICE_CV_MIKU #include "voice_miku_janken_raw.h" #include "voice_miku_pong_raw.h" #include "voice_miku_aikode_raw.h" #include "voice_miku_sho_raw.h" #include "voice_miku_yattane_raw.h" #include "voice_miku_zuko_raw.h" typedef struct{ u8 *address; u32 size; }DialogStatus; typedef struct{ DialogStatus dialog[VOICE_DIALOG_MAX]; }CVStatus; typedef struct{ int sound_id; CVStatus cv[VOICE_CV_MAX]; }VoiceStatus; static VoiceStatus st_voice; //--------------------------------------------------------------------------------- void Voice_Init(void){ //--------------------------------------------------------------------------------- memset(&st_voice, 0, sizeof(st_voice)); soundEnable(); //VOICE_CV_ORG st_voice.cv[VOICE_ORG].dialog[VOICE_JANKEN].address = (u8*)voice_org_janken_raw; st_voice.cv[VOICE_ORG].dialog[VOICE_JANKEN].size = voice_org_janken_raw_size; st_voice.cv[VOICE_ORG].dialog[VOICE_AIKODE].address = (u8*)voice_org_aikode_raw; st_voice.cv[VOICE_ORG].dialog[VOICE_AIKODE].size = voice_org_aikode_raw_size; st_voice.cv[VOICE_ORG].dialog[VOICE_PONG].address = (u8*)voice_org_pong_raw; st_voice.cv[VOICE_ORG].dialog[VOICE_PONG].size = voice_org_pong_raw_size; st_voice.cv[VOICE_ORG].dialog[VOICE_SHO].address = (u8*)voice_org_sho_raw; st_voice.cv[VOICE_ORG].dialog[VOICE_SHO].size = voice_org_sho_raw_size; st_voice.cv[VOICE_ORG].dialog[VOICE_YATTANE].address = (u8*)voice_org_yattane_raw; st_voice.cv[VOICE_ORG].dialog[VOICE_YATTANE].size = voice_org_yattane_raw_size; st_voice.cv[VOICE_ORG].dialog[VOICE_ZUKO].address = (u8*)voice_org_zuko_raw; st_voice.cv[VOICE_ORG].dialog[VOICE_ZUKO].size = voice_org_zuko_raw_size; //VOICE_CV_MIKU st_voice.cv[VOICE_MIKU].dialog[VOICE_JANKEN].address = (u8*)voice_miku_janken_raw; st_voice.cv[VOICE_MIKU].dialog[VOICE_JANKEN].size = voice_miku_janken_raw_size; st_voice.cv[VOICE_MIKU].dialog[VOICE_AIKODE].address = (u8*)voice_miku_aikode_raw; st_voice.cv[VOICE_MIKU].dialog[VOICE_AIKODE].size = voice_miku_aikode_raw_size; st_voice.cv[VOICE_MIKU].dialog[VOICE_PONG].address = (u8*)voice_miku_pong_raw; st_voice.cv[VOICE_MIKU].dialog[VOICE_PONG].size = voice_miku_pong_raw_size; st_voice.cv[VOICE_MIKU].dialog[VOICE_SHO].address = (u8*)voice_miku_sho_raw; st_voice.cv[VOICE_MIKU].dialog[VOICE_SHO].size = voice_miku_sho_raw_size; st_voice.cv[VOICE_MIKU].dialog[VOICE_YATTANE].address = (u8*)voice_miku_yattane_raw; st_voice.cv[VOICE_MIKU].dialog[VOICE_YATTANE].size = voice_miku_yattane_raw_size; st_voice.cv[VOICE_MIKU].dialog[VOICE_ZUKO].address = (u8*)voice_miku_zuko_raw; st_voice.cv[VOICE_MIKU].dialog[VOICE_ZUKO].size = voice_miku_zuko_raw_size; } //--------------------------------------------------------------------------------- void Voice_Play(VOICE_CV cv, VOICE_DIALOG dialog){ //--------------------------------------------------------------------------------- Voice_Stop(); st_voice.sound_id = soundPlaySample(st_voice.cv[cv].dialog[dialog].address, SoundFormat_16Bit, st_voice.cv[cv].dialog[dialog].size, 11025, 64, 64, false, 0); } //--------------------------------------------------------------------------------- void Voice_Stop(void){ //--------------------------------------------------------------------------------- soundKill(st_voice.sound_id); } //---------------------------------------------------------------------------------