int main()                                    // Main function
{
  int a;
  sirc_setTimeout(1000);
  while(1)
  {
    a=sirc_button(3);
    if(a==16)
    {
      wav_play("ouch.wav");
      pause(1000);
    }      
    else if(a==17)
    {
      wav_play("no.wav");
      pause(1000);
    }      
    else if(a==18)
    {
      wav_play("meow.wav");
      pause(1500);
    } 
    else if(a==19)
    {
      wav_play("hello1.wav");
      pause(1500);
    } 

  }  
}
Example #2
0
void* playpcm_thread(void* arg) {
	struct audiotest_thread_context *context =
		(struct audiotest_thread_context*) arg;
	int ret_val;

	ret_val = wav_play(&context->config);
	free_context(context);
	pthread_exit((void*) ret_val);

    return NULL;
}
Example #3
0
int main(int argc, char **argv)
{
    const char *fn = 0;
    int play = 1;
    unsigned channels = 1;
    unsigned rate = 44100;

    argc--;
    argv++;
    while (argc > 0) {
        if (!strcmp(argv[0],"-rec")) {
            play = 0;
        } else if (!strcmp(argv[0],"-play")) {
            play = 1;
        } else if (!strcmp(argv[0],"-stereo")) {
            channels = 2;
        } else if (!strcmp(argv[0],"-mono")) {
            channels = 1;
        } else if (!strcmp(argv[0],"-rate")) {
            argc--;
            argv++;
            if (argc == 0) {
                fprintf(stderr,"playwav: -rate requires a parameter\n");
                return -1;
            }
            rate = atoi(argv[0]);
        } else {
            fn = argv[0];
        }
        argc--;
        argv++;
    }

    if (fn == 0) {
        fn = play ? "/data/out.wav" : "/data/rec.wav";
    }

    if (play) {
        const char *dot = strrchr(fn, '.');
        if (dot && !strcmp(dot,".mp3")) {
            return mp3_play(fn);
        } else {
            return wav_play(fn);
        }
    } else {
        return wav_rec(fn, channels, rate);
    }
	return 0;
}
Example #4
0
static int isowavPlayLBA(int LBA)
{
	isowavLBA = LBA;

	for (isowavTrack = isowavTOC->FirstTrack - 1; isowavTrack < isowavTOC->LastTrack; isowavTrack++) {
		if (isowavLBA < isowavMSFToLBA(isowavTOC->TrackData[isowavTrack + 1].Address)) {
			break;
		}
	}

	if (isowavTrack >= isowavTOC->LastTrack) {
		return 1;
	}

	bprintf(PRINT_IMPORTANT, _T("    playing track %2i - %s\n"), isowavTrack + 1, isowavTOC->TrackData[isowavTrack].Filename);

	isowavFile = _tfopen(isowavTOC->TrackData[isowavTrack].Filename, _T("rb"));
	if (isowavFile == NULL) {
		return 1;
	}

	if(	_tcsstr(isowavTOC->TrackData[isowavTrack].Filename, _T(".wav")) || _tcsstr(isowavTOC->TrackData[isowavTrack].Filename, _T(".WAV"))) {
		// is a wav, no need to keep this file pointer
		if (isowavFile) {
			fclose(isowavFile);
			isowavFile = NULL;
		}
		
		if(wav_open(isowavTOC->TrackData[isowavTrack].Filename)) {
			wav_play();
		} else {
			// error creating the WAV stream
			return 1;
		}
	}

	//dprintf(_T("*** WAV: wBitsPerSample: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->wBitsPerSample);
	//dprintf(_T("*** WAV: nAvgBytesPerSec: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->nAvgBytesPerSec);
	//dprintf(_T("*** WAV: m_dwSize: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_dwSize);
	//dprintf(_T("*** WAV: nBlockAlign: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->nBlockAlign);

	isowavLBA = isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address);
	CDEmuStatus = playing;

	return 0;
}
int main()                                        // main function
{
  int DO = 22, CLK = 23, DI = 24, CS = 25;        // SD I/O pins
  sd_mount(DO, CLK, DI, CS);                      // Mount SD card
 
  const char techloop[] = {"techloop.wav"};       // Set up techloop string
  wav_play(techloop);                             // Pass to wav player
 
  wav_volume(6);                                  // Adjust volume
  pause(3500);                                    // Play for 3.5 s
  wav_volume(4);                                  // Repeat twice more
  pause(2000);
  wav_volume(8);
  pause(3500);

  wav_stop();                                      // Stop playing
}
int main()                                    // main function
{
  int DO = 22,CLK = 23, DI = 24, CS = 25;
  sd_mount(DO,CLK,DI,CS);
  wav_volume(10);
  freqout(4, 2000, 3000);                     // Speaker tone: P4, 2 s, 3 kHz
  while(1)                                    // Endless loop
  {
    int wL = input(7);                        // Left whisker -> wL variable
    int wR = input(8);                        // Right whisker -> wR variable
    //print("%c", HOME);                        // Terminal cursor home (top-left)
    //print("wL = %d  wR = %d", wL, wR);        // Display whisker variables
    drive_speed(128,128);
    if(input(7)==0 || input(8) == 0)
    {
    drive_speed(0,0);
    pause(500);
    wav_play("ouch.wav");
    drive_goto(-64,64);
    }
  }
}
Example #7
0
void select_file_action(void *arg) {
	int selected = *((int *) arg);
	int i, j, k, fd, size;
	volatile uint8_t *tmp;
	
	switch(selected) {
		case 0:
			fd = fat_open(path, O_RDONLY);
			size = fat_fsize(fd);
	
			for(j = 0; j < size; j += 512) {
				terminal_clear();
				fat_read_sect(fd);
				for(i = 0; i < 512; i++) {
					if(fat_buf[i] < 32 || fat_buf[i] > 126)
						printf("?");
					else
						printf("%c", fat_buf[i]);
					
				}
				input_poll();
			}
			fat_close(fd);
			break;
		case 1:
			fd = fat_open(path, O_RDONLY);
			size = fat_fsize(fd);
	
			for(j = 0; j < size; j += 512) {
				terminal_clear();
				printf("\nSector %u\n", j >> 9);
				fat_read_sect(fd);
				for(i = 0; i < 256; i+=16) {
					tmp =((uint8_t *) fat_buf) + i;
					printf("%04x\t%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\t\t", 
						j + i,
						tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], 
						tmp[8], tmp[9], tmp[10], tmp[11], tmp[12], tmp[13], tmp[14], tmp[15]
					);
					for(k = 0; k < 16; k++) {
						if(tmp[k] < 32 || tmp[k] > 126)
							printf(".");
						else
							printf("%c", tmp[k]);
					}
					printf("\n");
					
				}
				input_poll();
				terminal_clear();
				printf("\nSector %u\n", j >> 9);
				for(i = 256; i < 512; i+=16) {
					tmp =((uint8_t *) fat_buf) + i;
					printf("%04x\t%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\t\t", 
						j + i,
						tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], 
						tmp[8], tmp[9], tmp[10], tmp[11], tmp[12], tmp[13], tmp[14], tmp[15]
					);
					for(k = 0; k < 16; k++) {
						if(tmp[k] < 32 || tmp[k] > 126)
							printf(".");
						else
							printf("%c", tmp[k]);
					}
					printf("\n");
					
				}
				input_poll();
			}
			fat_close(fd);

			break;
		case 2:
			{
				void *addr, *entry;
				fd = fat_open(path, O_RDONLY);
				if(hexload(get_byte, fd, hexload_write_byte, NULL, &entry) < 0) {
					printf("Invalid hex file");
					fat_close(fd);
					input_poll();
					break;
				}
				fat_close(fd);
				fd = fat_open(path, O_RDONLY);
				
				if(hexload(get_byte, fd, hexload_verify_byte, NULL, &addr) < 0) {
					printf("Hexload validate error at 0x%X\n", addr);
					fat_close(fd);
					input_poll();
					break;
				}
				
				__asm__ __volatile__ ("cpusha %dc\n");
				goto *addr;
				
				fat_close(fd);
				input_poll();
			}
			break;
		case 4:
			fd = fat_open(path, O_RDONLY);
			size = fat_fsize(fd);
			tmp = MEM_VGA_RAM;
			
			for(j = 512; j < size; j += 512) {
				fat_read_sect(fd);
				for(i = 0; i < 512; i++) {
					*tmp++ = fat_buf[i];
				}
			}
			fat_read_sect(fd);
			for(i = 0; i < j - size; i++) {
				*tmp++ = fat_buf[i];
			}
			
			fat_close(fd);
			input_poll();
			terminal_clear();
			break;
		case 5:
			load_hex_to_rom(path);
			input_poll();
			
			break;
		
		case 6:
			terminal_clear();
			printf("Loading WAV to RAM\n");
			
			fd = fat_open(path, O_RDONLY);
			size = fat_fsize(fd);
			tmp = (volatile uint8_t *) SDRAM_BASE;
			
			printf("0/%u kB", size >> 10);
		
			for(j = 0; j < size; j += 512) {
				fat_read_sect(fd);
				for(i = 0; i < 512; i++) {
					*tmp++ = fat_buf[i];
				}
				printf("\r%u/%u kB", j >> 10, size >> 10);
			}
			fat_close(fd);
			printf("\n");
			wav_play((uint8_t *) SDRAM_BASE);
			printf("Press any key\n");
			input_poll();
			terminal_clear();
	}
}
Example #8
0
void wav_play_at( Wav *wav, int channel )
{
    if ( !audio_ok ) return;
    wav->channel = channel;
    wav_play( wav );
}