void fifo_interrupt_handler() {
	uint32_t i = 0;

	while(i++ < MAX_FIFO_SAMPLES && !XAC97_isInFIFOFull(XPAR_AXI_AC97_0_BASEADDR)){
//		uint32_t soundData = getCurrentSample();
		uint32_t soundData = getMixedSample();
		uint32_t sample = soundData | (soundData<<16); // Shifting to put in Left and Right
		XAC97_mSetInFifoData(XPAR_AXI_AC97_0_BASEADDR, sample); // Writing to the FIFO
	}
}
Exemplo n.º 2
0
//helper function for audio
static void playSound(int* samples, int num_samples){
	uint32_t stop = 0;
	static uint32_t i = 0;
	if(!readyForSound){
		while(i < num_samples && stop != MAX_NUM_SAMPLES){
			XAC97_mSetInFifoData(XPAR_AXI_AC97_0_BASEADDR, *(samples+i) << 16 | *(samples+i));
			i++;
			stop++;
		}
	}else{
		while(stop != MAX_NUM_SAMPLES){
			XAC97_mSetInFifoData(XPAR_AXI_AC97_0_BASEADDR, 0);
			stop++;
		}
		return;
	}
	if(i == num_samples){
		i = 0;
		readyForSound = true;
		num_samples = 0;
	}
	return;
}
Exemplo n.º 3
0
void sound_writeToFifo(int count)
{
	int i;
	for(i = 0; i < count; i++)
	{
		// If there is no sound playing, push zeros into the queue.
		uint16_t data = playingSound ? (128 + currentSound.soundData[currentSoundPosition]) : 0;

		// Bits 0-15 are right channel, 16-31 are left channel. Our audio only has one channel, so we will use it for both channels.
		XAC97_mSetInFifoData(XPAR_AXI_AC97_0_BASEADDR, (data | data << 16));

		// Advance position
		currentSoundPosition++;
		if(currentSoundPosition >= currentSound.numberOfSamples)
			playingSound = false;
	}
}