void Psp2Audio::SE_Play(std::string const& file, int volume, int pitch) {
	// Opening file
	FILE* stream = FileFinder::fopenUTF8(file, "rb");
	if (!stream) {
		Output::Warning("Couldn't open sound file %s", file.c_str());
		return;
	}

	// Pick the next free SE slot.
	// Does not need synchronisation
	int idx = -1;
	for (int i = 0; i < AUDIO_CHANNELS; ++i) {
		if (sfx_sounds[i].isPlaying && sfx_sounds[i].isFinished) {
			idx = i;
			break;
		}
	}

	if (idx == -1) {
		fclose(stream);
		Output::Warning("SE: No free channels available (%s)", file.c_str());
		return;
	}

	DecodedSound& sfx = sfx_sounds[idx];

	sfx.decoder = AudioDecoder::Create(stream, file);
	if (sfx.decoder == nullptr){
		fclose(stream);
		Output::Warning("Unsupported sound format (%s)", file.c_str());
		return;
	}

	// Initializing internal audio decoder
	int audiotype;

	AudioDecoder* decoder = sfx.decoder.get();

	if (!decoder->Open(stream)) {
		Output::Warning("Error occured in audio decoder (%s)", audio_decoder->GetError().c_str());
		return;
	}

	decoder->SetLooping(false);
	AudioDecoder::Format int_format;
	int samplerate;
	decoder->SetFormat(48000, AudioDecoder::Format::S16, 2);
	decoder->GetFormat(samplerate, int_format, audiotype);
	if (samplerate != 48000) Output::Warning("Cannot resample sound file. Sound will be distorted.");

	// Check for file audiocodec
	sfx.isStereo = audiotype == 2;

	// Setting default streaming values
	sfx.cur_audiobuf = sfx.audiobuf;

	decoder->SetPitch(pitch);
	decoder->SetVolume(volume);

	// Wait and signal is required to prevent reordering
	sceKernelWaitSema(SFX_Mutex_ID, 1, NULL);
	sfx.isPlaying = false;
	sfx.isFinished = false;
	sceKernelSignalSema(SFX_Mutex_ID, 1);

	// Start one SE thread
	sceKernelSignalSema(SFX_Mutex, 1);
}