예제 #1
0
void RecSeq(TSequencer * s)
{
        StopSeq(s);
        printf("Record\n");
        s->state = recording;
        MidiSetRcvAlarm(s->ref, RecRcv);
}
예제 #2
0
void PlaySeq(TSequencer * s)
{
        MidiEvPtr e;
        
        StopSeq(s);
        printf("Play\n");
        if (e = First(s->seq)) {
                s->state = playing;
                PlayTask(MidiGetTime(), s->ref, s, e, 0);
        }
}
예제 #3
0
//---------------------------------------------------------------------------------
int main() {
	u32 i=0;
//---------------------------------------------------------------------------------
	readUserSettings();

	irqInit();
	// Start the RTC tracking IRQ
	initClockIRQ();
	fifoInit();

	//mmInstall(FIFO_MAXMOD);
	InstallSoundSys();

	SetYtrigger(80);

	installWifiFIFO();
	installSoundFIFO();

	installSystemFIFO();

	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_VBLANK, VblankHandler);

	irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);
	
	setPowerButtonCB(powerButtonCB);   

	// Keep the ARM7 mostly idle
	while (!exitflag) {
		if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) {
			exitflag = true;
		}
		swiWaitForVBlank();
		if(seq_status==STATUS_FADING)
		{
			if(i<24)
			{
				i+=10;
			}
			else
			{
				i-=24;
				ADSR_mastervolume--;
				if(!ADSR_mastervolume)
					StopSeq();
			}
		}
	}
	return 0;
}
예제 #4
0
파일: template.c 프로젝트: fincs/SSEQPlayer
int main(int argc, char* argv[])
{
	consoleDemoInit();
	InstallSoundSys();

	iprintf("\n\n\tSSEQ player PoC v1\n");
	iprintf("\tfincs.drunkencoders.com\n");
	iprintf("\tgithub.com/fincs");

	if (argc < 4)
	{
		if (!nitroFSInit())
		{
			error("Can't initialize NitroFS!");
			anykey();
			return 0;
		}
		if (defaultLoad(&g_sseqData, &g_sbnkData, g_swarData) != 0)
		{
			anykey();
			return 0;
		}
	}else
	{
		if (!fatInitDefault())
		{
			error("Can't initialize FAT!");
			anykey();
			return 0;
		}
		if (argvLoad(argc-1, argv+1, &g_sseqData, &g_sbnkData, g_swarData) != 0)
		{
			anykey();
			return 0;
		}
	}

	PlaySeq(g_sseqData, g_sbnkData, g_swarData);

	for(;;)
	{
		swiWaitForVBlank();

		scanKeys();
		if (keysDown() & KEY_START) break;
		if (keysDown() & KEY_B) StopSeq();
	}

	return 0;
}
예제 #5
0
void PlaySeq(const char* seqFile, const char* bnkFile, const char* war1, const char* war2, const char* war3, const char* war4)
{
	StopSeq();
	free_seq();
	curr_seq.msg = SNDSYS_PLAYSEQ;

	LoadFile(&curr_seq.seq, seqFile);
	LoadFile(&curr_seq.bnk, bnkFile);
	LoadFile(curr_seq.war + 0, war1);
	LoadFile(curr_seq.war + 1, war2);
	LoadFile(curr_seq.war + 2, war3);
	LoadFile(curr_seq.war + 3, war4);

	fifoSendDatamsg(FIFO_SNDSYS, sizeof(curr_seq), (u8*) &curr_seq);
}
예제 #6
0
int main( int argc, char *argv[])
{
        char            c;
        TSequencer      mySequencer;
        
	OpenSeq(&mySequencer, argv[1]);
	    
	printf ( "\nmsMidiPlayer <midifile> \n\n");
	printf ( "msMidiPlayer plays a MIDIfile\n\n");
	printf ( "Use p or P to start playing\n");
	printf ( "Use s or S to stop playing\n");
	printf ( "Use l or L to start playing and loop\n");
	printf ( "Use q or Q to quit the application\n\n");
        
        while ((c = getchar()) && c != 'q' && c != 'Q')  switch (c) {
	
	        case 'P': case 'p': PlaySeq(&mySequencer); break;
                case 'S': case 's': StopSeq(&mySequencer); break;
		case 'L': case 'l': PlayLoop(&mySequencer); break;
        }
        
        CloseSeq(&mySequencer);
}
예제 #7
0
int main(int _argc, char **_argv)
{
    consoleDemoInit();
    InstallSoundSys();

    argc=_argc;
    argv=_argv;
    if(!fatInitDefault())
    {
        iprintf("Filesystem FAIL");
        for(;;) swiWaitForVBlank();
    }

    CurrentFile = 0;

    ReadDIR();
    ShowDIR();

    CurrentSPS=malloc(768);
    if(readFrontend(CurrentSPS)) {
        ReadSPS();
    } else {
        free(CurrentSPS);
        CurrentSPS=NULL;
    }

    for(;;)
    {
        if(CurrentSSEQ != LastSSEQ)
        {
            LastSSEQ = CurrentSSEQ;
            scrollpos = 0;
            scrollposcounter = 10;
        }
        if(CurrentFile != LastFile)
        {
            LastFile = CurrentFile;
            scrollpos = 0;
            scrollposcounter = 10;
        }

        if(scrollposcounter==0)
        {
            scrollposcounter=10;
            if(!scrollposdirection)
            {
                //RIGHT
                if(scrollpos<scrollposmax)
                {
                    scrollpos++;
                }
                else
                {
                    scrollposdirection = 1;
                    scrollposcounter = 120;
                }
            }
            else
            {
                //LEFT
                if(scrollpos>0)
                {
                    scrollpos--;
                }
                else
                {
                    scrollposdirection = 0;
                    scrollposcounter = 120;
                }
            }
        }
        else
        {
            scrollposcounter--;
        }
        if(!PlayMode)
        {
            message_pointer = 0;	//Ignore any incoming debug messages.
            if(SSEQMode)
                ShowSSEQ();
            else
                ShowDIR();
        }
        swiWaitForVBlank();
        if(PlayMode)
        {
            j = message_pointer;
            for(i=0; i<j; i+=6)
            {
                if(message_data[i])
                {
#ifdef SNDSYS_DEBUG
                    iprintf("cmd = %.2X:%.2X",message_data[i+1],message_data[i+2]);
                    if(message_data[i]==3)
                        iprintf(":%.2X\n",message_data[i+3]);
                    else
                        iprintf("\n");
#endif
                    switch (message_data[i+1])
                    {
#ifdef SNDSYS_DEBUG
                    case 0x00:
                        iprintf("00 Unrecognized record: %d\n",message_data[i+2]);
                        break;
                    case 0x04:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("04 SEQUENCE IS MULTI-TRACK\n");
                        break;
                    case 0x03:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("03 SEQUENCE IS SINGLE-TRACK\n");
                        break;
                    case 0x05:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("05 CREATED TRACK %d\n",message_data[i+2]);
                        break;
#endif
                    case 0x06:
                        if(PlayMode)
                            iprintf("06 SEQUENCE STOPPED\n");
                        if(PlayMode && AutoPlay && !ManualStop)
                        {
                            if(CurrentSSEQ < SSEQCount - 1)
                            {
                                CurrentSSEQ++;
                                ReadSSEQ();
                            }

                        }
                        ManualStop = false;
                        break;
                    case 0x07:
                        if(PlayMode)
                            iprintf("07 Track has looped twice\n");
                        if(PlayMode && AutoPlay)
                        {
                            FadeSeq();
                        }
                        break;
                    case 0x08:
                        if(PlayMode)
                            iprintf("08 Track has ended\n");
                        if(PlayMode && AutoPlay)
                        {
                            if(CurrentSSEQ < SSEQCount - 1)
                            {
                                CurrentSSEQ++;
                                ReadSSEQ();
                            }
                        }
                        break;

                    case 0xC1: // Track Volume
                        iprintf("%X:", message_data[i+5]);
                        iprintf("C1     Track Volume: %d\n", message_data[i+2]);
                        break;

                    case 0xC2: // MASTER VOLUME
                        iprintf("%X:", message_data[i+5]);
                        iprintf("C2    MASTER VOLUME: %d\n", message_data[i+2]);
                        break;

#ifdef SNDSYS_DEBUG
                    case 0x94: // JUMP
                        iprintf("%X:",message_data[i+5]);
                        iprintf("94     POSITION JUMP:\n");
                        break;
                    case 0xC3: // TRANSPOSE
                        iprintf("C3         TRANSPOSE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xC8: // TIE
                        iprintf("C8               TIE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xC9: // PORTAMENTO
                        iprintf("C9        PORTAMENTO: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCA: // MODULATION DEPTH
                        iprintf("CA  MODULATION DEPTH: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCB: // MODULATION SPEED
                        iprintf("CB  MODULATION SPEED: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCC: // MODULATION TYPE
                        iprintf("CC   MODULATION TYPE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCD: // MODULATION RANGE
                        iprintf("CD  MODULATION RANGE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCE: // PORTAMENTO ON/OFF
                        iprintf("CE PORTAMENTO ON/OFF: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCF: // PORTAMENTO TIME
                        iprintf("CF   PORTAMENTO TIME: %.2X\n",message_data[i+2]);
                        break;
                    case 0xD4: //LOOP START
                        iprintf("%X:",message_data[i+5]);
                        iprintf("D4        LOOP START: %d\n",message_data[i+2]);
                        break;
                    case 0xD6: // PRINT VAR
                        iprintf("D6         PRINT VAR: %.2X\n",message_data[i+2]);
                        break;

                    case 0xE0: // MODULATION DELAY
                        iprintf("E0  MODULATION DELAY: %.2X %.2X\n",message_data[i+2],message_data[i+3]);
                        break;
                    case 0xE3: // SWEEP PITCH
                        iprintf("E3       SWEEP PITCH: %.2X %.2X\n",message_data[i+2],message_data[i+3]);
                        break;
                    case 0xFC:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("FC          LOOP END:\n");
                        break;
                    case 0xFF:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("FF      END OF TRACK:\n");
                        break;
                    default:
                        iprintf("%.2X  Unrecognized cmd: %.2X %.2X %.2X",message_data[i+1],message_data[i+2],message_data[i+3],message_data[i+4]);
                        break;
#endif
                    }
                }
            }
            message_pointer -= j;
        }
        scanKeys();
        if (keysDown() & KEY_A)
        {
            if(PlayMode)
            {
                fifoSendDatamsg(FIFO_SNDSYS, sizeof(curr_seq), (u8*) &curr_seq);	//User may have stopped current sequence.
            }
            else
            {
                if(SSEQMode)
                {
                    ReadSSEQ();
                }
                else
                {
                    if (CurrentSPS != NULL)
                    {
                        free(CurrentSPS);
                    }

                    CurrentSPS = malloc(23 + strlen(DIRList[CurrentFile])+1);
                    strcpy(CurrentSPS, "/data/NDS Music Player/");
                    strcat(CurrentSPS, DIRList[CurrentFile]);
                    CurrentSPS[23 + strlen(DIRList[CurrentFile])]=0;

                    ReadSPS();
                }
            }
        }

        if (keysDown() & KEY_B)
        {
            if(PlayMode)
            {
                PlayMode = false;
                SSEQMode = true;
                ShowSSEQ();
            }
            else
            {
                if(SSEQMode)
                {
                    SSEQMode = false;
                    ShowDIR();
                }
                else
                {
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_X)
        {
            ManualStop = true;
            StopSeq();
        }
        if (keysDown() & KEY_Y)
        {
            ManualStop = true;
            FadeSeq();
        }

        if(keysDown() & KEY_SELECT)
        {
            AutoPlay = !AutoPlay;
            if(PlayMode)
            {
                if(AutoPlay)
                    iprintf("Auto Play enabled\n");
                else
                    iprintf("Auto Play disabled\n");
            }
        }

        if(keysDown() & KEY_START)
        {
            PauseSeq();
        }

        if (keysDown() & KEY_UP)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ > 0)
                    {
                        CurrentSSEQ--;
                    }
                    else
                    {
                        CurrentSSEQ = SSEQCount - 1;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile > 0)
                    {
                        CurrentFile--;
                    }
                    else
                    {
                        CurrentFile = FileCount;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_DOWN)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ < SSEQCount - 1)
                    {
                        CurrentSSEQ++;
                    }
                    else
                    {
                        CurrentSSEQ = 0;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile < FileCount)
                    {
                        CurrentFile++;
                    }
                    else
                    {
                        CurrentFile = 0;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_LEFT)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ >= 23)
                    {
                        CurrentSSEQ -= 23;
                    }
                    else
                    {
                        CurrentSSEQ = 0;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile >= 23)
                    {
                        CurrentFile -= 23;
                    }
                    else
                    {
                        CurrentFile = 0;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_RIGHT)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ < (SSEQCount - 24))
                    {
                        CurrentSSEQ += 23;
                    }
                    else
                    {
                        CurrentSSEQ = SSEQCount - 1;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile < (FileCount - 24))
                    {
                        CurrentFile += 23;
                    }
                    else
                    {
                        CurrentFile = FileCount;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_L)
        {
            if (PlayMode)
            {
                if(CurrentSSEQ > 0)
                {
                    CurrentSSEQ--;
                }
                else
                {
                    CurrentSSEQ = SSEQCount - 1;
                }
                ReadSSEQ();
            }
        }

        if (keysDown() & KEY_R)
        {
            if (PlayMode)
            {
                if(CurrentSSEQ < SSEQCount - 1)
                {
                    CurrentSSEQ++;
                }
                else
                {
                    CurrentSSEQ = 0;
                }
                ReadSSEQ();
            }
        }
    }
}
예제 #8
0
void PlaySeqNDS(const char* ndsFile, const u32 SSEQOffset, const u32 SSEQSize, const u32 BANKOffset, const u32 BANKSize, const u32 WAVEARC1Offset, const u32 WAVEARC1Size, const u32 WAVEARC2Offset, const u32 WAVEARC2Size, const u32 WAVEARC3Offset, const u32 WAVEARC3Size, const u32 WAVEARC4Offset, const u32 WAVEARC4Size)
{
	StopSeq();
	swiWaitForVBlank();
	swiWaitForVBlank();
	//free_seq();
	curr_seq.msg = SNDSYS_PLAYSEQ;

	if((SSEQOffset==curr_seq_offset[0])&&(SSEQSize==curr_seq_size[0]))
	{
		iprintf("SSEQ Already Loaded.\n");
	}
	else
	{
		free_pdata(&curr_seq.seq);
		curr_seq_offset[0]=SSEQOffset;
		curr_seq_size[0]=SSEQSize;
		iprintf("Loading SSEQ.\n");
		LoadNDS(&curr_seq.seq, ndsFile, SSEQOffset, SSEQSize);
	}

	if((BANKOffset==curr_seq_offset[1])&&(BANKSize==curr_seq_size[1]))
	{
		iprintf("BANK Already Loaded.\n");
	}
	else
	{
		free_pdata(&curr_seq.bnk);
		curr_seq_offset[1]=BANKOffset;
		curr_seq_size[1]=BANKSize;
		iprintf("Loading BANK.\n");
		LoadNDS(&curr_seq.bnk, ndsFile, BANKOffset, BANKSize);
	}

	if((WAVEARC1Offset==curr_seq_offset[2])&&(WAVEARC1Size==curr_seq_size[2]))
	{
		if(WAVEARC1Offset != 0)
			iprintf("WAVEARC1 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 0);
		curr_seq_offset[2]=WAVEARC1Offset;
		curr_seq_size[2]=WAVEARC1Size;
		if(WAVEARC1Offset != 0)
		{
			iprintf("Loading WAVEARC1.\n");
			LoadNDS(curr_seq.war + 0, ndsFile, WAVEARC1Offset, WAVEARC1Size);
		}
	}
	
	if((WAVEARC2Offset==curr_seq_offset[3])&&(WAVEARC2Size==curr_seq_size[3]))
	{
		if(WAVEARC2Offset != 0)
			iprintf("WAVEARC2 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 1);
		curr_seq_offset[3]=WAVEARC2Offset;
		curr_seq_size[3]=WAVEARC2Size;
		if(WAVEARC2Offset != 0)
		{
			iprintf("Loading WAVEARC2.\n");
			LoadNDS(curr_seq.war + 1, ndsFile, WAVEARC2Offset, WAVEARC2Size);
		}
	}

	if((WAVEARC3Offset==curr_seq_offset[4])&&(WAVEARC3Size==curr_seq_size[4]))
	{
		if(WAVEARC3Offset != 0)
			iprintf("WAVEARC3 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 2);
		curr_seq_offset[4]=WAVEARC3Offset;
		curr_seq_size[4]=WAVEARC3Size;
		if(WAVEARC3Offset != 0)
		{
			iprintf("Loading WAVEARC3.\n");
			LoadNDS(curr_seq.war + 2, ndsFile, WAVEARC3Offset, WAVEARC3Size);
		}
	}

	if((WAVEARC4Offset==curr_seq_offset[5])&&(WAVEARC4Size==curr_seq_size[5]))
	{
		if(WAVEARC4Offset != 0)
			iprintf("WAVEARC4 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 3);
		curr_seq_offset[5]=WAVEARC4Offset;
		curr_seq_size[5]=WAVEARC4Size;
		if(WAVEARC4Offset != 0)
		{
			iprintf("Loading WAVEARC4.\n");
			LoadNDS(curr_seq.war + 3, ndsFile, WAVEARC4Offset, WAVEARC4Size);
		}
	}

	fifoSendDatamsg(FIFO_SNDSYS, sizeof(curr_seq), (u8*) &curr_seq);
}
예제 #9
0
void CloseSeq(TSequencer * s)
{
        StopSeq(s);
        MidiFreeSeq(s->seq);
        MidiClose(s->ref);
}