Exemple #1
0
int main(int argc, char *argv[])
{
    int error;
    static mWaveState *state;

    MIDASstartup();

    puts("MIDAS RIFF WAVE reader test\n");

    if ( argc != 2 )
    {
        puts("Usage: musfade wavefile");
        return 1;
    }

    puts("Opening file and reading info");
    if ( (error = mWaveOpen(argv[1], &state)) != OK )
        MIDASerror(error);

    printf("Sample type = %u\n", state->sampleType);
    printf("Sample rate = %u\n", state->sampleRate);
    printf("Data length = %u bytes\n", state->dataLength);
    printf("Data offset = %u\n", state->dataStart);

    puts("Closing file");
    if ( (error = mWaveClose(state)) != OK )
        MIDASerror(error);

    return 0;
}
Exemple #2
0
void musapois()
{
        if ( !MIDASsetMusicSyncCallback(playHandle, NULL) )
                MIDASerror();
        for ( int i = 0; i < MAXSAMPLES; i++ )
                if ( (error = vuRemove(i)) != OK ) midasError(error);
        if ( (error = vuClose()) != OK )
                midasError(error);
        if ( !MIDASstopModule(playHandle) ) MIDASerror();
        if ( !MIDASfreeModule(module) ) MIDASerror();
        if ( !MIDASremoveTimerCallbacks() )
                MIDASerror();
        if ( !MIDASclose() ) MIDASerror();
}
Exemple #3
0
void PollThread(void *dummy)
#endif
{
    unsigned c;
    
    dummy = dummy;

    while ( !stopPoll )
    {
        c = GetCycleCount();
        if ( !MIDASpoll() )
            MIDASerror();
        c = GetCycleCount() - c;
        if ( pollCount > 100 )
        {
            if ( c < pollMin )
                pollMin = c;
            if ( c > pollMax )
                pollMax = c;
            pollTotal += c;
        }
        pollCount++;
        Sleep(rand() % 40);
        if ( (rand() % 8) < 3 )
            RandomPriority();
    }

    stopPoll = 0;

    _endthread();
}
Exemple #4
0
int main(void)
{
	MIDASmodule module;
	MIDASmodulePlayHandle playHandle;
	int i;
	FILE *f;

	remove("c:\\crn_cmn.mrk");

	if(!MIDASstartup()) {
		printf("Unable to initialize MIDAS sound system\n");
		getch();
		exit(0);
	}

	if(!MIDASinit()) MIDASerror();
	if(!MIDASstartBackgroundPlay(0)) MIDASerror();

	if((module = MIDASloadModule("cadmium.xm")) == NULL) MIDASerror();

	if((i = WinExec("..\\crn_cmn.exe", SW_SHOWMAXIMIZED )) == 0) {
		printf("Unable to execute crn_cmn.exe\n");
		MIDASclose();
		getch();
		exit(0);
	}

	while(1) {
		sleep(1000);
		if((f = fopen("c:\\crn_cmn.mrk", "rb")) !=  NULL) {
			fclose(f);
			break;
		}
	}

	playHandle = MIDASplayModule(module, TRUE);

	while(1) {
		sleep(1000);
		if((f = fopen("c:\\crn_cmn.mrk", "rb")) ==  NULL) break;
		else fclose(f);
	}

	MIDASclose();

	return 0;
}
Exemple #5
0
void musa(char moduleName[])
{
        musainit();
//        if ( (module = MIDASloadModule(moduleName)) == NULL ) MIDASerror();
        if ( (error = gmpLoadIT(moduleName, 1, &MakeMeter, &module)) != OK )
                midasError(error);
        if ( (playHandle = MIDASplayModule(module, TRUE)) == 0 ) MIDASerror();
}
Exemple #6
0
int musainit()
{
        midasSetDefaults();
        MIDASstartup();
        if (!MIDASdetectSoundCard()) MIDASerror();
        refreshRate = MIDASgetDisplayRefreshRate();
        if ( refreshRate == 0 ) {
/*                cout << "Warning! Unable to synchronize to display refresh!\n";
                if ( getch() == 27 ) return 0;*/
                refreshRate = 70000; /* default 70Hz */
        }
        if ( !MIDASinit() ) MIDASerror();
        if ( (error = vuInit()) != OK )
                midasError(error);
        if ( !MIDASsetTimerCallbacks(refreshRate, TRUE, &prevr, NULL, NULL) )
                MIDASerror();
        return 0;
}
Exemple #7
0
int main(int argc, char *argv[]) {
    union REGS regs;
    byte breakout = 0;
    int i,j,f,k=0;
    long oldCount = 0;
    int width = 320;
    int height = 200;
    int comp = 0;
    int req_comp = 0;
    int pixel_pos = 0;

    char str1[] = "hello, synctracker!\n";
    byte *image_pixelbuffer = malloc(320 * 200);
    byte *image_palettebuffer = malloc(256 * 3);


    /* Unbuffer stdout: */
    setbuf(stdout, NULL);

    /* Prevent warnings: */
    argc = argc;
    argv = argv;

    start = *my_clock;

    system("cls");
    printf("Please wait...");
    connectToCOM1();

    loader();

    /* Play the tune */
    if ( (playHandle = MIDASplayModule(module, TRUE)) == 0 ) {
        MIDASerror();
    }
    startTime = 0;
    currentTime = 0;
    prevTime = 0;
    passedTime = 0;

    set_mode(VGA_256_COLOR_MODE);
    while ( !kbhit() ) {
        currentTime = frameCount / 60.0f;
        passedTime = frameCount - prevTime;
        prevTime = currentTime;

        displayImage(background);
        demo();
        wait_for_retrace();
        UpdateInfo();
    }

    midasMagicDies();
    set_mode(TEXT_MODE);
    return 0;
}
Exemple #8
0
void MIDAS_CALL UpdateInfo(void) {   
    static MIDASplayStatus status;

    /* Get playback status: */
    if ( !MIDASgetPlayStatus(playHandle, &status) )
        MIDASerror();

    /* Store interesting information in easy-to-access variables: */
    position = status.position;
    pattern = status.pattern;
    row = status.row;
    syncInfo = status.syncInfo;
}
Exemple #9
0
void MIDAS_CALL UpdateInfo(void)
{
    /* MIDAS_CALL is cdecl for Watcom, empty for DJGPP. Helps calling this
       from assembler, otherwise unnecessary */
    
    static MIDASplayStatus status;

    /* Get playback status: */
    if ( !MIDASgetPlayStatus(playHandle, &status) )
        MIDASerror();

    /* Store interesting information in easy-to-access variables: */
    position = status.position;
    pattern = status.pattern;
    row = status.row;
    syncInfo = status.syncInfo;
}
Exemple #10
0
int main(int argc, char *argv[])
{
    char        oldTitle[256];
    unsigned    i;
/*    char        *foo;*/

    MIDASstartup();
    
    /* Keep the test somewhat reproducable: */
    srand(17);

    setbuf(stdout, NULL);

    puts("MIDAS stream test\n\n"
         "The sound output may sound strange, but the program should _NOT_ "
         "crash");

    puts("Trying to get window handle");

    /* Hack - try to figure out our console window's window handle: */
    GetConsoleTitle(oldTitle, 255);
    SetConsoleTitle("DirectSound TestiKala");
    Sleep(250);
    EnumWindows(&EnumWindowsProc, (LPARAM) NULL);
    SetConsoleTitle(oldTitle);

    printf("%P, %u\n", consoleHwnd, sizeof(HWND));

    if ( consoleHwnd == NULL )
        Error("Couldn't find window handle");

    puts("Trying to use DirectSound primary buffer mode");
    MIDASsetOption(MIDAS_OPTION_DSOUND_HWND, (DWORD) consoleHwnd);
    MIDASsetOption(MIDAS_OPTION_DSOUND_MODE, MIDAS_DSOUND_PRIMARY);

    /* Initialize MIDAS and start background playback: */
    if ( !MIDASinit() )
        MIDASerror();
/*    if ( !MIDASstartBackgroundPlay(0) )
        MIDASerror();*/

#ifdef _MSC_VER   
    if ( _beginthread(PollThread, 4096, NULL) == -1 )
        Error("Unable to create polling thread");
#else    
    if ( _beginthread(PollThread, NULL, 4096, NULL) == -1 )
        Error("Unable to create polling thread");
#endif    

    /* Open enough channels: */
    if ( !MIDASopenChannels(32) )
        MIDASerror();

    /* Allocate some channels for automatic effects: */
    if ( !MIDASallocAutoEffectChannels(12) )
        MIDASerror();

    /* Load the initial module and sample: */
    puts("Loading modules");
    if ( (module1 = MIDASloadModule(MODULE1)) == NULL )
        MIDASerror();
    if ( (module2 = MIDASloadModule(MODULE2)) == NULL )
        MIDASerror();
    puts("Loading samples");
    if ( (sample1 = MIDASloadRawSample(SAMPLE1, MIDAS_SAMPLE_8BIT_MONO, FALSE))
         == 0 )
        MIDASerror();
    if ( (sample2 = MIDASloadRawSample(SAMPLE2, MIDAS_SAMPLE_16BIT_MONO,
                                       FALSE)) == 0 )
         MIDASerror();

    /* Swap stuff out: */
    /*
    puts("Touching a LOT of memory");
    if ( (foo = malloc(64*1024*1024)) == NULL )
        Error("Out of memory");
    for ( i = 0; i < (64*1024*1024); i++ )
        foo[i] = (i & 255);
        */

    puts("Playing stream");
    if ( (stream1 = MIDASplayStreamWaveFile(STREAM1, 500, TRUE)) == NULL )
        MIDASerror();

    /* Play the module: */
    puts("Playing module");
    if ( (playHandle1 = MIDASplayModule(module1, TRUE)) == 0 )
        MIDASerror();

    /* Play effects for a while: */
    puts("Playing samples");
    for ( i = 0; i < 1000; i++ )
    {
        switch ( rand() & 8 )
        {
            case 0:
                if ( MIDASplaySample(sample1, MIDAS_CHANNEL_AUTO, 0, 22050 +
                                     ((rand() % 30000) - 15000), rand() % 24,
                                     (rand() % 128) - 64) == 0 )
                    MIDASerror();
                break;

            case 8:
                if ( MIDASplaySample(sample2, MIDAS_CHANNEL_AUTO, 0, 22050 +
                                     ((rand() % 30000) - 15000), rand() % 24,
                                     (rand() % 128) - 64) == 0 )
                    MIDASerror();
                break;
        }
                
        Sleep(rand() % 27);
        if ( (rand() % 8) < 2 )
            RandomPriority();

        printf("%u\n", MIDASgetStreamBytesBuffered(stream1));
    }

    puts("Stopping");

    stopPoll = 1;
    while ( stopPoll )
        Sleep(10);

    if ( !MIDASstopStream(stream1) )
        MIDASerror();
    /* Stop playback and uninitialize MIDAS: */
/*    if ( !MIDAScloseChannels() )
        MIDASerror();*/
/*    if ( !MIDASstopBackgroundPlay() )
        MIDASerror();*/
    if ( !MIDASclose() )
        MIDASerror();

    printf("Poll total %u, min %u, max %u, avg %u, count %u\n", pollTotal,
           pollMin, pollMax, pollTotal/(pollCount-100), pollCount);

    return 0;
}
Exemple #11
0
int main(int argc, char *argv[])
{
    int error;
    MIDASmodule module;
    MIDASmodulePlayHandle playHandle;
    static mEchoHandle eh;

    MIDASstartup();

    puts("MIDAS echo effect engine test\n");

    if ( argc != 2 )
    {
        puts("Usage: echo module");
        return 1;
    }

    MIDASsetOption(MIDAS_OPTION_MIXING_MODE, MIDAS_MIX_HIGH_QUALITY);
    if ( !MIDASinit() )
        MIDASerror();
    if ( !MIDASstartBackgroundPlay(0) )
        MIDASerror();

    if ( (error = mEchoInit()) != OK )
        mError(error);

    if ( (module = MIDASloadModule(argv[1])) == NULL )
        MIDASerror();
    
    if ( (playHandle = MIDASplayModule(module, TRUE)) == 0 )
        MIDASerror();

    
    if ( (error = mEchoAddEffect(&simpleEcho, &eh)) != OK )
        mError(error);

    puts("Simple echo - press any key");
    getch();

    if ( (error = mEchoRemoveEffect(eh)) != OK )
        mError(error);

    if ( (error = mEchoAddEffect(&reverseEcho, &eh)) != OK )
        mError(error);

    puts("Channel-reverse echo - press any key");
    getch();

    if ( (error = mEchoRemoveEffect(eh)) != OK )
        mError(error);

    puts("No echo - press any key");
    getch();

    if ( !MIDASstopModule(playHandle) )
        MIDASerror();
    if ( !MIDASfreeModule(module) )
        MIDASerror();

    if ( (error = mEchoClose()) != OK )
        mError(error);
    
    if ( !MIDASstopBackgroundPlay() )
        MIDASerror();
    if ( !MIDASclose() )
        MIDASerror();

    return 0;
}
Exemple #12
0
int main(int argc, char *argv[])
{
    MIDASmodule module;
    MIDASmodulePlayHandle playHandle;

    MIDASstartup();

#ifdef _WIN32_
    SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS);
#endif    

    puts("MIDAS playback profiler\n");

    if ( argc != 3 )
    {
        puts("Usage: mode filename\n        mode = (f)loat/(i)nteger\n");
        return EXIT_FAILURE;
    }

    MIDASconfig();

    switch ( argv[1][0] )
    {
        case 'i':
            mPreferredMixingMode = M_MIX_INTEGER;
            break;

        case 'f':
            mPreferredMixingMode = M_MIX_FLOAT;
            break;
    }

    if ( !MIDASinit() )
        MIDASerror();
    if ( !MIDASstartBackgroundPlay(0) )
        MIDASerror();
    
    if ( (module = MIDASloadModule(argv[2])) == NULL )
        MIDASerror();
    if ( (playHandle = MIDASplayModule(module, TRUE)) == 0 )
        MIDASerror();

    printf("Playing - press any\n");
    getch();

    if ( !MIDASstopModule(playHandle) )
        MIDASerror();
    if ( !MIDASfreeModule(module) )
        MIDASerror();

    if ( !MIDASstopBackgroundPlay() )
        MIDASerror();

    PrintResults();
    
    if ( !MIDASclose() )
        MIDASerror();

    
    return 0;    
}