Ejemplo n.º 1
0
EXPORT(sqInt) primitiveSoundStop(void) {
	snd_Stop();
	if (interpreterProxy->failed()) {
		return null;
	}
	return null;
}
Ejemplo n.º 2
0
primitiveSoundStop(void)
{
	// SoundPlugin>>#primitiveSoundStop
	snd_Stop();
	if (failed()) {
		return null;
	}
	return null;
}
int snd_Start(int frameCount, int samplesPerSec, int stereo, int semaIndex)
{
    Synchronized<es::Monitor*> method(monitorPlayState);

    if (!gSoundOutput)
    {
        return false;
    }

    int bytesPerFrame;
    int bufferBytes;

    bytesPerFrame = stereo ? 2 * BYTES_PER_SAMPLE : BYTES_PER_SAMPLE;
    bufferBytes   = ((frameCount * bytesPerFrame) / 8) * 8;

    if (playState.open)
    {
        // still open from last time; clean up before continuing
        snd_Stop();
    }

    int chan = (stereo ? 2 : 1);

    Handle<es::AudioFormat> audio(gSoundOutput);
    audio->setBitsPerSample(16);
    audio->setChannels(chan);
    audio->setSamplingRate(samplesPerSec);

    playState.bufSizeInBytes = bufferBytes * 2;
    playState.buffer = new u8[playState.bufSizeInBytes];
    if (!playState.buffer)
    {
        return false;
    }
    memset(playState.buffer, 0, playState.bufSizeInBytes);

    playState.open           = false;  // set to true if successful
    playState.stereo         = stereo;
    playState.frameCount     = bufferBytes / bytesPerFrame;
    playState.sampleRate     = samplesPerSec;
    playState.lastFlipTime   = ioMicroMSecs();
    playState.playSemaIndex  = semaIndex;
    playState.playing        = true;
    playState.head = playState.tail = playState.buffer;
    playState.done           = false;
    playState.open = true;
    monitorPlayState->notifyAll();

    return true;
}
Ejemplo n.º 4
0
void Sound_Tests(void)
{
	int i ;
	int j ;
	gfx_Cls() ;
	printf("Sound Tests\n") ;
	putstr("Sound Tests") ;
	snd_Volume(127) ;
	snd_BufSize(2) ;
	printf("Playing\n") ;
	file_PlayWAV(soundtest) ;
	sleep(10000) ;
	printf("Pausing\n") ;
	snd_Pause() ;
	sleep(5000) ;
	printf("Continuing\n") ;
	snd_Continue() ;
	sleep(5000) ;
	printf("Playing with pitch\n") ;
	i = snd_Pitch(0xFFFF) ;
	printf("Original Pitch=%d\n",i) ;
	sleep(5000) ;
	snd_Pitch(trunc(i*2 /*one octave, 1.0594631 one semitone*/)) ;
	sleep(5000) ;
	snd_Pitch(trunc(i/2)) ;
	sleep(5000) ;
	snd_Pitch(i) ;
	sleep(5000) ;
	for (j = 1; j <= 5; j++)
	{
		i = snd_Playing() ;
		printf("Blocks remaining=%d\r ",i) ;
		sleep(2000) ;
	}
	printf("\n") ;
	for (i = 127; i >= 8; i--)
	{
		snd_Volume(i) ; // 8 to 127 ;
		printf("Volume=%d\r ",i) ;
		sleep(100) ;
	}
	printf("\nStopping\n") ;
	snd_Stop() ;
}