Пример #1
0
int main()
{
	irqInit();
	fifoInit();

	readUserSettings();
	initClockIRQ();

	SetYtrigger(80);

	installSystemFIFO();

	irqSet(IRQ_VCOUNT, VCountHandler);
	irqSet(IRQ_VBLANK, 0);
	irqEnable(IRQ_VBLANK|IRQ_VCOUNT|IRQ_NETWORK);

	powerOn(POWER_SOUND);
	REG_SOUNDCNT = SOUND_ENABLE | SOUND_VOL(127);

	static Player oPlayer;
	Player_Init(& oPlayer);

	while ( 1 )
	{
		swiWaitForVBlank();

		Player_Execute(& oPlayer);
	}

	return 0;
}
Пример #2
0
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------

	// Reset the clock if needed
	rtcReset();

	//enable sound
	powerON(POWER_SOUND);
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	SetYtrigger(80);
	vcount = 80;
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);  
	
	irqSet(IRQ_TIMER0, playTimerHandler);
	irqEnable(IRQ_TIMER0);
	
	player = new Player(playTimerHandler);
	player->registerTickCallback(onTick);
	player->registerPatternChangeCallback(onPatternChange);

	// Keep the ARM7 idle
	while (1) swiWaitForVBlank();
}
Пример #3
0
void SoundEngine::initStreaming(int timerChannel)
{
    memset(buffer, 0, sizeof buffer);
    bufferIndex = 0;

    /*
     * Next timer tick will populate the first half of the buffer
     * (bufferIndex=0) but by the time we get there, the audio
     * hardware will already be started on the second half.  We want
     * the sound hardware and Timer 0 to stay synchronized, so that
     * they're always operating on opposite halves of 'buffer'.
     */
    timerStart(timerChannel,
               ClockDivider_256,
               timerFreqToTicks_256(SAMPLE_RATE / SAMPLES_PER_FRAME),
               timerCallback);

    /*
     * Start playing a circular sound buffer that holds 2 frames.
     */
    SCHANNEL_SOURCE(CHANNEL_PCSPEAKER)       = (uint32_t) &buffer[0];
    SCHANNEL_REPEAT_POINT(CHANNEL_PCSPEAKER) = 0;
    SCHANNEL_LENGTH(CHANNEL_PCSPEAKER)       = BUFFER_SIZE / sizeof(uint32_t);
    SCHANNEL_TIMER(CHANNEL_PCSPEAKER)        = SOUND_FREQ(SAMPLE_RATE);
    SCHANNEL_CR(CHANNEL_PCSPEAKER)           = SCHANNEL_ENABLE |
                                               SOUND_VOL(127) |
                                               SOUND_PAN(64) |
                                               SOUND_REPEAT |
                                               SOUND_FORMAT_8BIT;
}
Пример #4
0
int main(int argc, char **argv)
{
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR ;
    
    u32 old_reg = readPowerManagement(PM_CONTROL_REG);
    writePowerManagement(PM_CONTROL_REG, old_reg |PM_LED_ON); // enable fast
    
	// Reset the clock if needed
	rtcReset();

	// Turn on Sound
	powerON(POWER_SOUND);

	// Set up sound defaults.
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	// Set up the interrupt handler
	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	irqEnable(IRQ_VBLANK);

     // Setup FIFO
     
 	irqSet(IRQ_FIFO_NOT_EMPTY,FifoInterruptHandler);
	irqEnable(IRQ_FIFO_NOT_EMPTY);     
    REG_IPC_FIFO_CR =  IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ ;
    
	// Keep the ARM7 out of main RAM
	while (1)
		swiWaitForVBlank();
	
	return 0;
}
Пример #5
0
//---------------------------------------------------------------------------------
void startSound(int sampleRate, const void* data, u32 bytes, u8 channel, u8 vol,  u8 pan, u8 format) {
//---------------------------------------------------------------------------------
	SCHANNEL_TIMER(channel)  = SOUND_FREQ(sampleRate);
	SCHANNEL_SOURCE(channel) = (u32)data;
	SCHANNEL_LENGTH(channel) = bytes >> 2 ;
	SCHANNEL_CR(channel)     = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT);
}
Пример #6
0
void restartsound(int ch) {
	chan = ch;

	SCHANNEL_CR(0)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x3F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(1)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x3F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(2)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x3F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(3)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x2F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(4)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x7F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(5)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x60)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(6)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x7F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(7)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x7F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;
	SCHANNEL_CR(8)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x7F)|SOUND_PAN(0x40)|SOUND_FORMAT_16BIT;

	SCHANNEL_CR(10)=SCHANNEL_ENABLE|SOUND_REPEAT |SOUND_VOL(0x7F)|SOUND_PAN(0x40)|SOUND_FORMAT_8BIT;

	TIMER0_CR = TIMER_ENABLE; 
	TIMER1_CR = TIMER_CASCADE | TIMER_IRQ_REQ | TIMER_ENABLE;
}
Пример #7
0
void initsound() { 		
	int i;
	powerOn(POWER_SOUND); 
	REG_SOUNDCNT = SOUND_ENABLE | SOUND_VOL(0x7F);
	for(i = 0; i < 16; i++) {
		SCHANNEL_CR(i) = 0;
	}
	SCHANNEL_SOURCE(0)=(u32)&buffer[0];
	SCHANNEL_SOURCE(1)=(u32)&buffer[2*MIXBUFSIZE];
	SCHANNEL_SOURCE(2)=(u32)&buffer[4*MIXBUFSIZE];
	SCHANNEL_SOURCE(3)=(u32)&buffer[6*MIXBUFSIZE];
	SCHANNEL_SOURCE(4)=(u32)&buffer[8*MIXBUFSIZE];
	SCHANNEL_SOURCE(5)=(u32)&buffer[10*MIXBUFSIZE];
	SCHANNEL_SOURCE(6)=(u32)&buffer[12*MIXBUFSIZE];
	SCHANNEL_SOURCE(7)=(u32)&buffer[14*MIXBUFSIZE];
	SCHANNEL_SOURCE(8)=(u32)&buffer[16*MIXBUFSIZE];
	SCHANNEL_SOURCE(10)=(u32)&buffer[18*MIXBUFSIZE];
	SCHANNEL_TIMER(0)=-0x2b9; 
	SCHANNEL_TIMER(1)=-0x2b9; 
	SCHANNEL_TIMER(2)=-0x2b9; 
	SCHANNEL_TIMER(3)=-0x2b9; 
	SCHANNEL_TIMER(4)=-0x2b9; 
	SCHANNEL_TIMER(5)=-0x2b9; 
	SCHANNEL_TIMER(6)=-0x2b9; 
	SCHANNEL_TIMER(7)=-0x2b9; 
	SCHANNEL_TIMER(8)=-0x2b9; 
	SCHANNEL_TIMER(10)=-0x2b9; 
	SCHANNEL_LENGTH(0)=MIXBUFSIZE;
	SCHANNEL_LENGTH(1)=MIXBUFSIZE;
	SCHANNEL_LENGTH(2)=MIXBUFSIZE;
	SCHANNEL_LENGTH(3)=MIXBUFSIZE;
	SCHANNEL_LENGTH(4)=MIXBUFSIZE;
	SCHANNEL_LENGTH(5)=MIXBUFSIZE;
	SCHANNEL_LENGTH(6)=MIXBUFSIZE;
	SCHANNEL_LENGTH(7)=MIXBUFSIZE;
	SCHANNEL_LENGTH(8)=MIXBUFSIZE;
	SCHANNEL_LENGTH(10)=MIXBUFSIZE / 2;
	SCHANNEL_REPEAT_POINT(0) = 0; 
	SCHANNEL_REPEAT_POINT(1) = 0; 
	SCHANNEL_REPEAT_POINT(2) = 0; 
	SCHANNEL_REPEAT_POINT(3) = 0; 
	SCHANNEL_REPEAT_POINT(4) = 0; 
	SCHANNEL_REPEAT_POINT(5) = 0; 
	SCHANNEL_REPEAT_POINT(6) = 0; 
	SCHANNEL_REPEAT_POINT(1) = 0; 
	SCHANNEL_REPEAT_POINT(8) = 0; 
	SCHANNEL_REPEAT_POINT(10) = 0; 
	TIMER0_DATA = -0x572;
	TIMER1_DATA = 0x10000 - MIXBUFSIZE;
	memset(buffer, 0, sizeof(buffer));

	memset(IPC_PCMDATA, 0, 512);
} 
Пример #8
0
void PA_Init(void){
 	rtcReset();

	//enable sound
	powerON(POWER_SOUND);
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;
	
	PA_NewSPI = PA_ReadSPI();
	IPC->aux = PA_NewSPI;
	
	MIC_On();
	PM_SetAmp(1);
}
Пример #9
0
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------
    // read User Settings from firmware
    readUserSettings();
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & prepare fifo asap
    rtcReset();

    //enable sound
    powerON(POWER_SOUND);
    writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
    SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);

    irqInit();

    // Start the RTC tracking IRQ
    initClockIRQ();

    SetYtrigger(80);
    irqSet(IRQ_VCOUNT, VcountHandler);
    irqSet(IRQ_VBLANK, VblankHandler);
    irqSet(IRQ_WIFI, Wifi_Interrupt); // set up wifi interrupt

    irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_WIFI);

    {   // sync with arm9 and init wifi
        u32 fifo_temp;

        while(1) { // wait for magic number
            while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
            fifo_temp=REG_IPC_FIFO_RX;
            if(fifo_temp==0x12345678) break;
        }
        while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
        fifo_temp=REG_IPC_FIFO_RX; // give next value to wifi_init
        Wifi_Init(fifo_temp);

        irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo); // set up fifo irq
        irqEnable(IRQ_FIFO_NOT_EMPTY);
        REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

        Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9
    } // arm7 wifi init complete


    // Keep the ARM7 mostly idle
    while (1) swiWaitForVBlank();
}
Пример #10
0
int main(int argc, char ** argv)
{
	u32 fifo_temp;   
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;

	// Reset the clock if needed
	rtcReset();

	//enable sound
	powerON(POWER_SOUND);
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	SetYtrigger(80);
	vcount = 80;
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);

	irqSet(IRQ_TIMER0, tob_ProcessMicrophoneTimerIRQ);
	tob_MIC_On();

	irqSet(IRQ_WIFI, Wifi_Interrupt);
	irqEnable(IRQ_WIFI);

	// trade some mail, to get a pointer from arm9
	while(1)
	{
		while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
		fifo_temp=REG_IPC_FIFO_RX;
		if(fifo_temp==0x12345678) break;
	}
	while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
	fifo_temp=REG_IPC_FIFO_RX;
	Wifi_Init(fifo_temp);

	irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo);
	irqEnable(IRQ_FIFO_NOT_EMPTY);
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

	Wifi_SetSyncHandler(arm7_synctoarm9);

	// Keep the ARM7 idle
	while(1) swiWaitForVBlank();
}
Пример #11
0
void startSound(int sampleRate, const void* data, uint32 bytes, u8 channel, u8 vol,  u8 pan, u8 format)
{
	SCHANNEL_TIMER(channel)  = SOUND_FREQ(sampleRate);
	SCHANNEL_SOURCE(channel) = (u32)data;
	SCHANNEL_LENGTH(channel) = bytes >> 2;
	u32 form = 0;
	switch(format)
	{
	case 0:
		form = SOUND_FORMAT_16BIT;
		break;
	case 1:
		form = SOUND_FORMAT_8BIT;
		break;
	case 2:
		form = SOUND_FORMAT_ADPCM;
		break;
	}
	SCHANNEL_CR(channel) = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | form;
}
Пример #12
0
void ds_adjustchannel(int channel, int vol, int pan)
{
	SCHANNEL_CR(channel)     = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (SOUND_FORMAT_8BIT);
}