void CWaveFormDrawer::draw(void *data,CRect r, CDC *pDC, int begin, int end)
{
	SoundData<short> *ptr = (SoundData<short> *)data;
	if(end < 0)
		end = ptr->getSamples();
	int numSamples = end - begin;
	CSize s;
	s.cx = r.Width();
	s.cy = r.Height();
	pDC->SetBkColor(RGB(0,0,0));
	pDC->SetBkMode(OPAQUE);
	if((int)ptr->getStereoMode() == 1)
	{
		drawMonoAxis(pDC,pDC->GetWindowExt());
		drawMonoWaveForm(data,pDC,s,begin,end);
	}
	else if((int)ptr->getStereoMode() == 2)
	{
		drawStereoAxis(pDC,pDC->GetWindowExt());
		drawStereoWaveForm(data,pDC,s,begin,end);
	}

//	SampleData<short> *pdat = data;

	
}
Exemple #2
0
int w_SoundData_getSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int)lua_tointeger(L, 2);
	lua_pushnumber(L, sd->getSample(i));
	return 1;
}
int w_SoundData_setSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int) luaL_checkinteger(L, 2);
	float sample = (float) luaL_checknumber(L, 3);

	EXCEPT_GUARD(sd->setSample(i, sample);)
	return 0;
Exemple #4
0
int w_SoundData_setSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int)lua_tointeger(L, 2);
	float sample = (float)lua_tonumber(L, 3);
	sd->setSample(i, sample);
	return 0;
}
int w_SoundData_clone(lua_State *L)
{
	SoundData *t = luax_checksounddata(L, 1), *c = nullptr;
	luax_catchexcept(L, [&](){ c = t->clone(); });
	luax_pushtype(L, c);
	c->release();
	return 1;
}
void Emitter::SetSoundData(sound::ISoundData* data)  {
	//FIXME error occurs in this function!
	SoundData* SFMLData = static_cast<SoundData*>(data);
	assert(pSFMLSoundSource == 0);
	delete pSFMLSoundSource; //FIXME error occurs at this deletion (virtual destructor used)
	pSFMLSoundSource = SFMLData->GetSFMLSoundData()->CreateSFMLSoundSource();

	soundData.Reset(SFMLData);
}
/**
 * Play sound repeatedly.
 * @param name sound name
 * @return the channel the sample is played on. On any errors, -1 is returned.
 */
int SDLSound::playSoundRepeatedly(const char* name)
{
    int channel = -1;
    SoundData *sdata = findChunk(name);
    if (sdata) {
        if ((channel = Mix_PlayChannel(-1, sdata->getData(), -1)) == -1) {
            LOG (("Couldn't play sound '%s': %s", name, Mix_GetError()));
        }
    }

    return channel;
}
Exemple #8
0
	bool SE::load(uint uID, int max_moment)
	{
		bool bResult = true;

		SoundData * soundd = new SoundData();
		bResult = soundd->load(uID);
		if (bResult == false) return false;

		bResult = set_sound_data(*soundd, max_moment);

		ownership = true;

		return bResult;
	}
int w_SoundData_getSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int) luaL_checkinteger(L, 2);

	if (lua_gettop(L) > 2)
	{
		int channel = luaL_checkinteger(L, 3);
		luax_catchexcept(L, [&](){ lua_pushnumber(L, sd->getSample(i, channel)); });
	}
	else
		luax_catchexcept(L, [&](){ lua_pushnumber(L, sd->getSample(i)); });
	return 1;
}
Exemple #10
0
	ErrorType SoundSource::Load(const String &fileName,
		SoundCollection *collection)
	{
		Stop();
		Bind(collection, collection->GetIDByName(fileName));
		if (-1 < mID)
			return kErrorNone;
		// No sound was found, load the sound data
		SoundData soundData;
		ErrorType error = soundData.Load(fileName);
		if (error)
			return Error::Throw(error, String("[%s(\"%s\")]",
				FastFunctionName, fileName.GetCString()));
		return LoadResource(fileName, soundData, collection);
	}
Exemple #11
0
	ErrorType SoundSource::Load(StreamReader *streamReader,
		SoundCollection *collection)
	{
		String name = streamReader->GetName();
		Stop();
		Bind(collection, collection->GetIDByName(name));
		if (-1 < mID)
			return kErrorNone;
		// No sound was found, load the sound data
		SoundData soundData;
		ErrorType error = soundData.Load(streamReader);
		if (error)
			return Error::Throw(error,
				String("[%s(%p): streamReader->mName=\"%s\"]",
					FastFunctionName, streamReader,
					streamReader->GetName().GetCString()));
		return LoadResource(name, soundData, collection);
	}
int w_SoundData_setSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int) luaL_checkinteger(L, 2);

	if (lua_gettop(L) > 3)
	{
		int channel = luaL_checkinteger(L, 3);
		float sample = (float) luaL_checknumber(L, 4);
		luax_catchexcept(L, [&](){ sd->setSample(i, channel, sample); });
	}
	else
	{
		float sample = (float) luaL_checknumber(L, 3);
		luax_catchexcept(L, [&](){ sd->setSample(i, sample); });
	}

	return 0;
}
/**
 * Play sound once.
 * @param name sound name
 */
void SDLSound::playSound(const char* name)
{
    SoundData *sdata = findChunk(name);
    if (sdata)
    {
        if ( sdata->last_played.isTimeOut() )
        {
            if (Mix_PlayChannel(-1, sdata->getData(), 0) == -1)
            {
                //LOG (("Couldn't play sound '%s': %s", name, Mix_GetError()));
            }
            sdata->last_played.reset();
        }
        else
        {
//            LOGGER.debug("Skipped sound '%s' due to timeout", name);
        }
        
    }
}
Exemple #14
0
	ErrorType SoundSource::Load(const SoundData &soundData,
		SoundCollection *collection)
	{
		String name = soundData.GetName();
		Stop();
		Bind(collection, collection->GetIDByName(name));
		if (-1 < mID)
			return kErrorNone;
		// No sound was found, load the sound data
		return LoadResource(name, soundData, collection);
	}
/**
 * Play sound once.
 * @param name sound name
 * @param distance mag2 distance
 */
void SDLSound::playAmbientSound(const char* name, long distance)
{
    SoundData *sdata = findChunk(name);
    if (sdata)
    {
        if ( sdata->last_played.isTimeOut() )
        {
            int oldVolume = Mix_VolumeChunk(sdata->getData(), getSoundVolume(distance));
            if (Mix_PlayChannel(-1, sdata->getData(), 0) == -1)
            {
                //LOG (("Couldn't play sound '%s': %s", name, Mix_GetError()));
            }
            Mix_VolumeChunk(sdata->getData(), oldVolume);
            sdata->last_played.reset();
        }
        else
        {
//            LOGGER.debug("Skipped ambient sound '%s' due to timeout", name);
        }
    }
}
Exemple #16
0
void SoundManager::addSound(const char* fileName, SOUND_TYPE type, bool isLoop)
{
    if (_dicSounds.at(fileName)) return;
    
    SoundData* data = new SoundData;
    data->setSoundKey(fileName);
    data->setSoundType(type);
    data->setIsLoop(isLoop);
    
    _dicSounds.insert(fileName, data);
    
    if (type == BGM)
    {
        SimpleAudioEngine::getInstance()->preloadBackgroundMusic(fileName);
    }
    else if (type == EFFECT)
    {
        SimpleAudioEngine::getInstance()->preloadEffect(fileName);
    }
    
    
}
Exemple #17
0
	ErrorType SoundSource::LoadResource(const String &name,
		const SoundData &soundData, SoundCollection *collection)
	{
		// Check for existing sound with matching checksum
		Checksum checksum(soundData.GetSamples().GetData(),
			soundData.GetSamples().GetElementCount());
		Bind(collection, collection->GetIDByChecksum(checksum));
		if (-1 < mID)
			return kErrorNone;
		// No sound was found, generate new buffer
		UInt openALID;
		alGenBuffers(1, &openALID);
		if (!openALID)
			return Error::Throw(kErrorOpenALGenBuffersFailure,
				String("[%s(\"%s\", %p)]", FastFunctionName,
				name.GetCString(), &soundData));
		SoundResource soundResource;
		soundResource.SetName(name);
		soundResource.SetChecksum(checksum);
		soundResource.GetProperties()->SetFormat(soundData.GetProperties().GetFormat());
		soundResource.GetProperties()->SetFrequency(soundData.GetProperties().GetFrequency());
		soundResource.GetProperties()->SetSampleCount(soundData.GetProperties().GetSampleCount());
		soundResource.SetOpenALBufferID(openALID);
		soundResource.SetActive(true);
		mID = collection->AddResource(soundResource, this);
		mCollection = collection;
		{
			alBufferData(GetResource().GetOpenALBufferID(),
				GetResource().GetProperties().GetFormat(),
				soundData.GetSamples().GetData(),
				soundData.GetSamples().GetElementCount(),
				GetResource().GetProperties().GetFrequency());
			ALint alErr = alGetError();
			switch (alErr)
			{
			case AL_OUT_OF_MEMORY:
				Unbind();
				return Error::Throw(kErrorOutOfMemory,
					String("[%s(\"%s\", %p)]", FastFunctionName,
					name.GetCString(), &soundData));
			case AL_INVALID_ENUM:
			case AL_INVALID_VALUE:
				Unbind();
				return Error::Throw(kErrorInvalidValue,
					String("[%s(\"%s\", %p)]", FastFunctionName,
					name.GetCString(), &soundData));
			}
		}
		return kErrorNone;
	}
Exemple #18
0
int SD_PlayDigitized(const SoundData &which,int leftpos,int rightpos,SoundChannel chan)
{
    if (!DigiMode)
        return 0;

    // If this sound has been played too recently, don't play it again.
    // (Fix for extremely loud sounds when one plays over itself too much.)
    uint32_t currentTick = SDL_GetTicks();
    if (currentTick - SoundInfo.GetLastPlayTick(which) < MIN_TICKS_BETWEEN_DIGI_REPEATS)
        return 0;

    SoundInfo.SetLastPlayTick(which, currentTick);

    int channel = chan;
    if(chan == SD_GENERIC)
    {
        channel = Mix_GroupAvailable(1);
        if(channel == -1) channel = Mix_GroupOldest(1);
        if(channel == -1)           // All sounds stopped in the meantime?
            channel = Mix_GroupAvailable(1);
    }
    SD_SetPosition(channel, leftpos,rightpos);

    DigiPlaying = true;

    Mix_Chunk *sample = reinterpret_cast<Mix_Chunk*> (which.GetData(SoundData::DIGITAL));
    if(sample == NULL)
        return 0;

    Mix_Volume(channel, static_cast<int> (ceil(128.0*MULTIPLY_VOLUME(SoundVolume))));
    if(Mix_PlayChannel(channel, sample, 0) == -1)
    {
        printf("Unable to play sound: %s\n", Mix_GetError());
        return 0;
    }

    // Return channel + 1 because zero is a valid channel.
    return channel + 1;
}
SoundData* WavReader::Read(const String& pFileName)
{
    SoundData* newSoundData = GD_NEW(SoundData, this, "SoundData");
    newSoundData->SetFileName(pFileName);

    Char identifier[5];
    identifier[4] = '\0';

    // Open the file stream.
    std::ifstream fileStream(pFileName.c_str(), std::ios::in | std::ios::binary);

    // Read "RIFF"
    fileStream.read(identifier, 4);
    if(strcmp(identifier, "RIFF") != 0)
        throw ResourceImportException( String("The wav file should start with RIFF"), Here );

    // Read the total length (filesize - 8).
    Int32 fileDataSize;
    fileStream.read((Char*)(&fileDataSize), 4);
    fileDataSize += 8;
    newSoundData->SetFileDataSize(fileDataSize);

    // Read "WAVE".
    fileStream.read(identifier, 4);
    if(strcmp(identifier, "WAVE") != 0)
        throw ResourceImportException( String("The wav file should contain the WAVE identifier."), Here );
    
    // Read "fmt_"
    fileStream.read(identifier, 4);
    if(strcmp(identifier, "fmt ") != 0)
        throw ResourceImportException( String("The wav file should contain the fmt_ identifier."), Here );
    
    // Read the Length of the format chunk.
    Int32 chunkFileSize;
    fileStream.read((Char*)(&chunkFileSize), 4);
 
    // Read a drummy short.
    Int16 dummyShort;
    fileStream.read((Char*)(&dummyShort), 2);

    // Read the number of channels.
    Int16 nbChannels;
    fileStream.read((Char*)(&nbChannels), 2);
    newSoundData->SetNbChannels(nbChannels);

    // Read the sample rate.
    Int32 sampleRate;
    fileStream.read((Char*)(&sampleRate), 4);
    newSoundData->SetSampleRate(sampleRate);

    // Read the bytes per second.
    Int32 bytesPerSecond;
    fileStream.read((Char*)(&bytesPerSecond), 4);
    newSoundData->SetBytesPerSecond(bytesPerSecond);

    // Read the bytes per sample.
    Int16 bytesPerSample;
    fileStream.read((Char*)(&bytesPerSample), 2);
    newSoundData->SetBytesPerSample(bytesPerSample);

    // Read the bits per sample.
    Int16 bitsPerSample;
    fileStream.read((Char*)(&bitsPerSample), 2);
    newSoundData->SetBitsPerSample(bitsPerSample);

    // Read "data"
    fileStream.read(identifier, 4);
    if(strcmp(identifier, "data") != 0)
        throw ResourceImportException( String("The wav file should contain the data identifier."), Here );

    // Read the size of sound data.
    Int32 soundDataSize;
    fileStream.read((Char*)(&soundDataSize), 4);
    newSoundData->SetSoundDataSize(soundDataSize);
    newSoundData->SetSoundDataOffset(44);
    
    // Read the data itself.
    fileStream.seekg(0, std::ios::beg);
    Char* data = GD_NEW_ARRAY(Char, fileDataSize + 1, this, "Data");
    data[fileDataSize] = '\0';
    fileStream.read(data, fileDataSize);
    newSoundData->SetFileData(data);

    fileStream.close();
 
    return newSoundData;
}
Exemple #20
0
int SoundManager::playEffect(string keyName)
{
    SoundData* data = _dicSounds.at(keyName);

    return SimpleAudioEngine::getInstance()->playEffect(data->getSoundKey(), data->getIsLoop());
}
Exemple #21
0
void SoundManager::playBgm(string keyName)
{
    SoundData* data = _dicSounds.at(keyName);
    SimpleAudioEngine::getInstance()->playBackgroundMusic(data->getSoundKey(), data->getIsLoop());
}
int w_SoundData_getBitDepth(lua_State *L)
{
	SoundData *t = luax_checksounddata(L, 1);
	lua_pushinteger(L, t->getBitDepth());
	return 1;
}
Exemple #23
0
int main(int argc, char *argv[])
{
    char *option;

    if ((argc != 3) || (*argv[1] != '-')) {
        usage();
        exit(1);
    }
    else {
        option = argv[1] + 1;
        if (*option == 'h') {
            usage();
            exit(1);
        }
        
        // Create an input bitstream
        Bitstream bs(argv[2], BS_INPUT);

        // Automatic detection
        if (*option == '-') {

            // Create our Audio object
            Audio audio;
        
            // Parse
            while (!bs.atend()) {
#ifdef USE_EXCEPTION
                try {
                    audio.get(bs); 
                    switch (audio.type) {
                    case 3: {   // WAV format
                        // For the data chunk, read one data element at a time
                        if (audio.wav->ckData->available) {
                            WAVData wd;
                            for (int i = 0; i < audio.wav->ckData->ckSize; i=i+audio.wav->ckFormat->bitsPerSample/8) 
                                wd.get(bs, audio.wav->ckFormat->bitsPerSample);
                            audio.wav->ckData->available = 0;
                        }
                        break;
                    }
                    case 2: {   // AIFF/AIFC format
                        // For the sound data chunk, read one data element at a time
                        if (audio.aiff->ckSound->available) {
                            SoundData sd;
                            for (int i = 0; i < audio.aiff->ckSound->ckSize; i++) 
                                sd.get(bs);
                            audio.aiff->ckSound->available = 0;
                        }
                        break;
                    }
                    case 1: {   // NeXT/Sun audio format
                        // Read one data element at a time
                        AUData aud;
                        for (int i = 0; i < audio.auh->dataSize; i++)
                            aud.get(bs);
                        break;
                    }
                    default:    // 8-bit raw format
                        break;
                    }
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else 
                audio.get(bs);
                switch (audio.type) {
                case 3: {   // WAV format
                    if (audio.wav->ckData->available) {
                        WAVData wd;
                        for (int i = 0; i < audio.wav->ckData->ckSize; i=i+audio.wav->ckFormat->bitsPerSample/8) 
                            wd.get(bs, audio.wav->ckFormat->bitsPerSample);
                        audio.wav->ckData->available = 0;
                    }
                    break;
                }
                case 2: {   // AIFF/AIFC format
                    if (audio.aiff->ckSound->available) {
                        SoundData sd;
                        for (int i = 0; i < audio.aiff->ckSound->ckSize; i++) 
                            sd.get(bs);
                        audio.aiff->ckSound->available = 0;
                    }
                    break;
                }
                case 1: {   // NeXT/Sun audio format
                    AUData aud;
                    for (int i = 0; i < audio.auh->dataSize; i++)
                        aud.get(bs);
                    break;
                }
                default:    // 8-bit raw format
                    break;
                }
                if (bs.geterror() == E_END_OF_DATA) {
                    fprintf(stdout, "End of file\n");
                    exit(1);
                }
                else if (bs.geterror() != E_NONE) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], bs.getmsg());
                    exit(1);
                }
#endif 
            }
        }

        // WAV format
        else if (*option == 'w') {
            printf("Reading a WAV file\n\n");

            WAV wav;
        
            // Parse
            while (1) {
#ifdef USE_EXCEPTION
                try {
                    wav.get(bs);
                    // Read one data element at a time
                    if (wav.ckData->available) {
                        WAVData wd;
                        for (int i = 0; i < wav.ckData->ckSize; i=i+wav.ckFormat->bitsPerSample/8) 
                            wd.get(bs, wav.ckFormat->bitsPerSample);
                        wav.ckData->available = 0;
                    }
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else  
                wav.get(bs);
                // Read one data element at a time
                if (wav.ckData->available) {
                    WAVData wd;
                    for (int i = 0; i < wav.ckData->ckSize; i=i+wav.ckFormat->bitsPerSample/8) 
                        wd.get(bs, wav.ckFormat->bitsPerSample);
                    wav.ckData->available = 0;
                }
                if (bs.geterror() == E_END_OF_DATA) {
                    fprintf(stdout, "End of file\n");
                    exit(1);
                }
                else if (bs.geterror() != E_NONE) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], bs.getmsg());
                    exit(1);
                }
#endif 
            }
        }
        // AIFF/AIFC format
        else if (*option == 'a') {
            printf("Reading an AIFF/AIFC file\n\n");

            AIFF aiff;
        
            // Parse
            while (1) {
#ifdef USE_EXCEPTION
                try {
                    aiff.get(bs);
                    // Read one data element at a time
                    if (aiff.ckSound->available) {
                        SoundData sd;
                        for (int i = 0; i < aiff.ckSound->ckSize; i++) 
                            sd.get(bs);
                        aiff.ckSound->available = 0;
                    }
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else 
                aiff.get(bs);
                // Read one data element at a time
                if (aiff.ckSound->available) {
                    SoundData sd;
                    for (int i = 0; i < aiff.ckSound->ckSize; i++)
                        sd.get(bs);
                }
                aiff.ckSound->available = 0;
                if (bs.geterror() == E_END_OF_DATA) {
                    fprintf(stdout, "End of file\n");
                    exit(1);
                }
                else if (bs.geterror() != E_NONE) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], bs.getmsg());
                    exit(1);
                }
#endif 
            }
        }
        // NeXT/Sun audio format
        else if (*option == 'n') {
            printf("Reading a NeXT/Sun audio file\n\n");

            AUHeader auh;
            AUData aud;
        
            // Parse
            while (1) {
#ifdef USE_EXCEPTION
                try {
                    auh.get(bs);
                    // Read one data element at a time
                    for (int i = 0; i < auh.dataSize; i++)
                        aud.get(bs);
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else 
        	    auh.get(bs);
                // Read one data element at a time
                for (int i = 0; i < auh.dataSize; i++)
                    aud.get(bs);
                if (bs.geterror() == E_END_OF_DATA) {
                    fprintf(stdout, "End of file\n");
                    exit(1);
                }
                else if (bs.geterror() != E_NONE) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], bs.getmsg());
                    exit(1);
                }
#endif 
            }
        }
        // Raw format
        else if (*option == 'r') {
            switch(*(argv[1] + 2)) {
            case '1':   
            {
                printf("Reading an 8-bit raw audio file\n\n");

                Raw8 raw;
        
                // Parse
#ifdef USE_EXCEPTION
                try {
                    raw.get(bs);
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else 
        	    raw.get(bs);
                if (bs.geterror() == E_END_OF_DATA) {
                    fprintf(stdout, "End of file\n");
                    exit(1);
                }
                else if (bs.geterror() != E_NONE) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], bs.getmsg());
                    exit(1);
                }
#endif 
                break;
            }

            case '2':
            {
                printf("Reading a 16-bit raw audio file\n\n");

                Raw16 raw;
        
                // Parse
#ifdef USE_EXCEPTION
                try {
                    raw.get(bs);
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else 
        	    raw.get(bs);
                if (bs.geterror() == E_END_OF_DATA) {
                    fprintf(stdout, "End of file\n");
                    exit(1);
                }
                else if (bs.geterror() != E_NONE) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], bs.getmsg());
                    exit(1);
                }
#endif 
                break;
            }

            case '3':
            {
                printf("Reading a 16-bit raw audio file (little-endian)\n\n");

                Raw16Little raw;
        
                // Parse
#ifdef USE_EXCEPTION
                try {
                    raw.get(bs);
                }
                catch (Bitstream::EndOfData e) {
		            fprintf(stdout, "End of file\n");
		            exit(1);
	            }
                catch (Bitstream::Error e) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], e.getmsg());
                    exit(1);
                }
#else 
        	    raw.get(bs);
                if (bs.geterror() == E_END_OF_DATA) {
                    fprintf(stdout, "End of file\n");
                    exit(1);
                }
                else if (bs.geterror() != E_NONE) {
                    fprintf(stderr, "%s: Error: %s\n", argv[2], bs.getmsg());
                    exit(1);
                }
#endif 
                break;
            }
            default:
                usage();
                exit(1);
            }
        }
        else {
            usage();
            exit(1);
        }
    }

    return 0;
}
Exemple #24
0
int w_SoundData_getDuration(lua_State *L)
{
	SoundData *t = luax_checksounddata(L, 1);
	lua_pushnumber(L, t->getDuration());
	return 1;
}
Exemple #25
0
int w_SoundData_getSampleCount(lua_State *L)
{
	SoundData *t = luax_checksounddata(L, 1);
	lua_pushinteger(L, t->getSampleCount());
	return 1;
}
Exemple #26
0
int w_SoundData_getChannels(lua_State *L)
{
	SoundData *t = luax_checksounddata(L, 1);
	lua_pushinteger(L, t->getChannels());
	return 1;
}