Esempio n. 1
0
void PlayerIdleState::onEnter()
{
	getContext().lock()->getParticle().setVelocity(irr::core::vector3df());
	auto spr = getContext().lock()->getSprite();
	spr->setLooping(true);
	spr->play(HashedString("idle"));
}
Esempio n. 2
0
void PlayerMobileState::onEnter()
{
	// GameApp::getSingleton().getLogger()->log("void PlayerMobileState::onEnter()");
	auto spr = getContext().lock()->getSprite();
	spr->setLooping(true);
	spr->play(HashedString("mobile"));
}
Esempio n. 3
0
File: Sample.cpp Progetto: cdj/Alamo
void Sample::generateWaveForm(vector<MiniMaxima> * _waveForm)
{

	_waveForm->clear();

	bool loopState = getIsLooping();
	setLooping(false);
	bool playState = getIsPlaying();
	double tmpSpeed = getSpeed();
	setSpeed(1.0f);
    play();
	// waveform display method based on this discussion http://answers.google.com/answers/threadview/id/66003.html

    double sampleL, sampleR;
	while ((long)position<getLength()) {

		MiniMaxima mm;
		mm.minL = mm.minR = mm.maxL = mm.maxR = 0;

		for (int i = 0; i < 256; i++){

		    if(myChannels == 1) {
                sampleL = update();
                sampleR = sampleL;
		    }
		    else {
                sampleL = update()*0.5;
                sampleR = update()*0.5;
		    }

			mm.minL = MIN(mm.minL, sampleL);
			mm.minR = MIN(mm.minR, sampleR);
			mm.maxL = MAX(mm.maxL, sampleL);
			mm.maxR = MAX(mm.maxR, sampleR);

		}

		_waveForm->push_back(mm);

 		//cout << mm.minR << " :: " << mm.maxR << " :: " << mm.minL << " :: " << mm.maxL << endl;
	}

	position = 0;
	setLooping(loopState);
	setSpeed(tmpSpeed);
	if(playState) play();
}
Esempio n. 4
0
void KRAudioSource::loadXML(tinyxml2::XMLElement *e)
{
    m_audio_sample_name = e->Attribute("sample");
    
    float gain = 1.0f;
    if(e->QueryFloatAttribute("gain", &gain)  != tinyxml2::XML_SUCCESS) {
        gain = 1.0f;
    }
    setGain(gain);
    
    float pitch = 1.0f;
    if(e->QueryFloatAttribute("pitch", &pitch) != tinyxml2::XML_SUCCESS) {
        pitch = 1.0f;
    }
    setPitch(m_pitch);
    
    bool looping = false;
    if(e->QueryBoolAttribute("looping", &looping) != tinyxml2::XML_SUCCESS) {
        looping = false;
    }
    setLooping(looping);
    
    bool is3d = true;
    if(e->QueryBoolAttribute("is3d", &is3d) != tinyxml2::XML_SUCCESS) {
        is3d = true;
    }
    setIs3D(is3d);
    
    float reference_distance = 1.0f;
    if(e->QueryFloatAttribute("reference_distance", &reference_distance) != tinyxml2::XML_SUCCESS) {
        reference_distance = 1.0f;
    }
    setReferenceDistance(reference_distance);
    
    float reverb = 0.0f;
    if(e->QueryFloatAttribute("reverb", &reverb) != tinyxml2::XML_SUCCESS) {
        reverb = 0.0f;
    }
    setReverb(reverb);
    
    float rolloff_factor = 2.0f;
    if(e->QueryFloatAttribute("rolloff_factor", &rolloff_factor) != tinyxml2::XML_SUCCESS) {
        rolloff_factor = 2.0f;
    }
    setRolloffFactor(rolloff_factor);
    
    m_enable_obstruction = true;
    if(e->QueryBoolAttribute("enable_obstruction", &m_enable_obstruction) != tinyxml2::XML_SUCCESS) {
        m_enable_obstruction = true;
    }

    m_enable_occlusion = true;
    if(e->QueryBoolAttribute("enable_occlusion", &m_enable_occlusion) != tinyxml2::XML_SUCCESS) {
        m_enable_occlusion = true;
    }
    
    KRNode::loadXML(e);
}
Esempio n. 5
0
void AIHurtState::onEnter()
{
	auto spr = getContext().lock()->getSprite();
	if (spr->hasSequence(HashedString("hurt")))
	{
		spr->setLooping(false);
		spr->play(HashedString("hurt"));
	}
}
Esempio n. 6
0
 // Loads the animation using data from a JSON structure
 void Animation::deserialize(Json::Value &configData)
 {
     std::string frame       = DataManager::getString(configData, "frame",   getFrameName());
     std::string extension   = DataManager::getString(configData, "ext",     getFrameExtension());
     int count               = DataManager::getInt   (configData, "frames",  getFrameCount());
     float delay             = DataManager::getFloat (configData, "delay",   getFrameDelay());
     init(frame, extension, count, delay);
     
     setName             (DataManager::getString (configData, "name",    getName()));
     setLooping          (DataManager::getBool   (configData, "loop",    isLooping()));
     allowEventGeneration(DataManager::getBool   (configData, "alert",   isGeneratingEvents()));
 }
 SourceTemplate::SourceTemplate(const std::string &sound, VSFileSystem::VSFileType type, bool _looping) throw() :
     soundName(sound),
     soundType(type),
     cosAngleRange(-1,-1),
     pfRadiusRatios(1,1),
     referenceFreqs(250,5000),
     gain(1)
 {
     setLooping(_looping);
     setStreaming(false);
     setRelative(false);
     setAttenuated(true);
 }
Esempio n. 8
0
void Sound::setDefaults()
{
  setPosition(Vector3::ZERO);
  setDirection(Vector3::UNIT_Y);
  setPitch(1.f);
  setGain(1.f, 0.f, 1.f);
  setLooping(false);
  setRolloff(1.f);
  setReferenceDistance(1.f);
  setCone(360.f,360.f,0.f);
  setRelative(true);
  setOffsetSeconds(0.f);
  rewind();
}
Esempio n. 9
0
void ObjetVolant::init()
{
    //Initialise les variables
    setZValue(1);
    setPilotage(manuel);
    setDessinerTrajectoire(false);
    creerImageParDefaut();
    setLooping(0);

    setVitesseAngulaireObjet(180.0 / 1000.0);
    setAccelerationObjet(100.0 / 1000000.0);
    setVitesseMinObjet(100.0 / 1000.0);
    setVitesseMaxObjet(300.0 / 1000.0);

    setPosition(QPointF(0, 0));
    setVitesseAngulaire(0);
    setAngle(vitesseAngulaire() * 0);
    setAcceleration(0);
    setVitesse(vitesseMinObjet());

    //Animation du looping
    animationLooping = new QPropertyAnimation(this, "looping");
    animationLooping->setDuration(500);
    animationLoopingRoot = new QSequentialAnimationGroup(this);
    animationLoopingRoot->addPause(1500); //Attend un moment avant de se retourner
    animationLoopingRoot->addAnimation(animationLooping);

    //Animation de la position
    animationPosition = new QPropertyAnimation(this, "position");
    animationPosition->setDuration(25);

    //Animation de l'angle
    setTransformOriginPoint(boundingRect().center()); //Met le centre de rotation au centre de l'Item
    animationAngle = new QPropertyAnimation(this, "angle");
    animationAngle->setDuration(25);

    //Animation de la vitesse
    animationVitesse = new QPropertyAnimation(this, "vitesse");
    animationVitesse->setDuration(25);

    //Animation principale des déplacements
    animationRoot = new QParallelAnimationGroup(this);
    animationRoot->addAnimation(animationAngle);
    animationRoot->addAnimation(animationVitesse);
    animationRoot->addAnimation(animationPosition);
    connect(animationRoot, SIGNAL(finished()), this, SLOT(seDeplacer()));

    temps.start();
    seDeplacer();
}
Esempio n. 10
0
bool STexture::openVideo(QString s, double fps, bool loop, int start, int stop)
{
    clearCallBacks();
    setPlaying(false);
    setFPS(fps);
    setLooping(loop);

    videoFileName = s;

    bool ok=false;
    for (physicalFirstFrame=0; physicalFirstFrame < (unsigned)max(20,max(start,stop)); physicalFirstFrame++)
    {
        QString fn = frameFilename(physicalFirstFrame);
        QFileInfo info(fn);
        if (info.isFile() && info.isReadable()) {
            ok=true;
            break;   
        }
    }
    if (!ok) {
        videoFileName.clear();
        return false;
    }
    unsigned in = physicalFirstFrame;
    unsigned out = 100000;
    while (out-in > 1) {
        int mid = in + ((out-in)/2);
        QString fn = frameFilename(mid);
        QFileInfo info(fn);
        if (info.isFile() && info.isReadable())
            in = mid;
        else
            out = mid;
    }
    physicalLastFrame=in;
    position=firstFrame=physicalFirstFrame;
    lastFrame=physicalLastFrame;

    if (start>=0) setFirstFrame(start);
    if (stop>=0) setLastFrame(stop);
    return true;
}
Esempio n. 11
0
bool BaseSoundBuffer::play(bool looping, uint32 startSample) {
	if (_handle) {
		g_system->getMixer()->stopHandle(*_handle);
		delete _handle;
		_handle = nullptr;
	}
	// Store the loop-value for save-games.
	setLooping(looping);
	if (_stream) {
		_stream->seek(startSample);
		_handle = new Audio::SoundHandle;
		if (_looping) {
			Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
			g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
		} else {
			g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO);
		}
	}

	return STATUS_OK;
}
Esempio n. 12
0
void PanoramicVideo::loadVideo(const std::string& path){
	if(mVideoSprite){
		mVideoSprite->release();
		mVideoSprite = nullptr;
	}

	// this does some dumb shit
	// any added children are listened to and linked to the video sprite
	// this is for the net sync stuff
	// there should be a better way to do this
	auto video_sprite = addChildPtr(new ds::ui::Video(mEngine));

	//Need to enable this to enable panning 
	video_sprite->generateAudioBuffer(true);
	video_sprite->setPan(mPanning);
	video_sprite->setPlayableInstances(mPlayableInstances);
	video_sprite->setAutoStart(true);
	video_sprite->setLooping(true);
	video_sprite->setAutoSynchronize(mAutoSync);
	video_sprite->loadVideo(path);
	video_sprite->setFinalRenderToTexture(true);

	resetCamera();
}
Esempio n. 13
0
void LoopMachine::addLoop(String groupName, File loopFile, float gain, LoopType type, int length) {
    int groupIx;
    if (!groupNameToIx.contains(groupName)) {
        groupIx = groupNameToIx.size();
        groupNameToIx.set(groupName, groupIx);
		groupIxToLoopInfo.add(new Array<LoopInfo *>);
    } else {
        groupIx = groupNameToIx[groupName];
    }
	AudioFormatReader* reader;
//	std::cout << "Loop file: " << loopFile.getFullPathName() << std::endl;
    if (loopFile.getFileName().endsWith("wav")) {
		reader = wavFormat.createReaderFor(new FileInputStream(loopFile), true);
	} else if (loopFile.getFileName().endsWith("caf")) {
		reader = cafFormat.createReaderFor(new FileInputStream(loopFile), true);
	} else {
		throw AudioEngineException("Unknown loop format.");
	}
	
	auto& groupInfo = *groupIxToLoopInfo[groupIx];
    auto src = new AudioFormatReaderSource(reader, true);
    src->setLooping(type == LoopType::LOOP);
	groupInfo.add(new LoopInfo{src, gain, length, type, String::empty});
}
status_t BnMediaPlayer::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case DISCONNECT: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            disconnect();
            return NO_ERROR;
        } break;
        case SET_VIDEO_SURFACE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder());
            reply->writeInt32(setVideoSurface(surface));
            return NO_ERROR;
        } break;
        case PREPARE_ASYNC: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(prepareAsync());
            return NO_ERROR;
        } break;
        case START: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(start());
            return NO_ERROR;
        } break;
        case STOP: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(stop());
            return NO_ERROR;
        } break;
        case IS_PLAYING: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            bool state;
            status_t ret = isPlaying(&state);
            reply->writeInt32(state);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case PAUSE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(pause());
            return NO_ERROR;
        } break;
        case SEEK_TO: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(seekTo(data.readInt32()));
            return NO_ERROR;
        } break;
        case GET_CURRENT_POSITION: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            int msec;
            status_t ret = getCurrentPosition(&msec);
            reply->writeInt32(msec);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case GET_DURATION: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            int msec;
            status_t ret = getDuration(&msec);
            reply->writeInt32(msec);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case RESET: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(reset());
            return NO_ERROR;
        } break;
        case SET_AUDIO_STREAM_TYPE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setAudioStreamType(data.readInt32()));
            return NO_ERROR;
        } break;
        case SET_LOOPING: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setLooping(data.readInt32()));
            return NO_ERROR;
        } break;
        case SET_VOLUME: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setVolume(data.readFloat(), data.readFloat()));
            return NO_ERROR;
        } break;
        case INVOKE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            invoke(data, reply);
            return NO_ERROR;
        } break;
        case SET_METADATA_FILTER: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setMetadataFilter(data));
            return NO_ERROR;
        } break;
        case SUSPEND: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(suspend());
            return NO_ERROR;
        } break;
        case RESUME: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(resume());
            return NO_ERROR;
        } break;
        case GET_METADATA: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            const status_t retcode = getMetadata(data.readInt32(), data.readInt32(), reply);
            reply->setDataPosition(0);
            reply->writeInt32(retcode);
            reply->setDataPosition(0);
            return NO_ERROR;
        } break;
        case SET_AUX_EFFECT_SEND_LEVEL: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setAuxEffectSendLevel(data.readFloat()));
            return NO_ERROR;
        } break;
        case ATTACH_AUX_EFFECT: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(attachAuxEffect(data.readInt32()));
            return NO_ERROR;
        } break;
#ifdef OMAP_ENHANCEMENT
        case REQUEST_CLONE_MODE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(requestVideoCloneMode(data.readInt32()));
            return NO_ERROR;
        } break;
#endif
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Esempio n. 15
0
void Kaboodle::Player::loop(void)
{
	setLooping(!isLooping());
}
status_t BnMediaPlayer::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case DISCONNECT: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            disconnect();
            return NO_ERROR;
        } break;
        case SET_DATA_SOURCE_URL: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            const char* url = data.readCString();
            KeyedVector<String8, String8> headers;
            int32_t numHeaders = data.readInt32();
            for (int i = 0; i < numHeaders; ++i) {
                String8 key = data.readString8();
                String8 value = data.readString8();
                headers.add(key, value);
            }
            reply->writeInt32(setDataSource(url, numHeaders > 0 ? &headers : NULL));
            return NO_ERROR;
        } break;
        case SET_DATA_SOURCE_FD: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            int fd = data.readFileDescriptor();
            int64_t offset = data.readInt64();
            int64_t length = data.readInt64();
            reply->writeInt32(setDataSource(fd, offset, length));
            return NO_ERROR;
        }
        case SET_DATA_SOURCE_STREAM: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            sp<IStreamSource> source =
                interface_cast<IStreamSource>(data.readStrongBinder());
            reply->writeInt32(setDataSource(source));
            return NO_ERROR;
        }
        case SET_VIDEO_SURFACETEXTURE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            sp<ISurfaceTexture> surfaceTexture =
                    interface_cast<ISurfaceTexture>(data.readStrongBinder());
            reply->writeInt32(setVideoSurfaceTexture(surfaceTexture));
            return NO_ERROR;
        } break;
        case PREPARE_ASYNC: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(prepareAsync());
            return NO_ERROR;
        } break;
        case START: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(start());
            return NO_ERROR;
        } break;
        case STOP: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(stop());
            return NO_ERROR;
        } break;
        case IS_PLAYING: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            bool state;
            status_t ret = isPlaying(&state);
            reply->writeInt32(state);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case PAUSE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(pause());
            return NO_ERROR;
        } break;
        case SEEK_TO: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(seekTo(data.readInt32()));
            return NO_ERROR;
        } break;
        case GET_CURRENT_POSITION: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            int msec;
            status_t ret = getCurrentPosition(&msec);
            reply->writeInt32(msec);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case GET_DURATION: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            int msec;
            status_t ret = getDuration(&msec);
            reply->writeInt32(msec);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case RESET: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(reset());
            return NO_ERROR;
        } break;
        case SET_AUDIO_STREAM_TYPE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setAudioStreamType(data.readInt32()));
            return NO_ERROR;
        } break;
        case SET_LOOPING: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setLooping(data.readInt32()));
            return NO_ERROR;
        } break;
        case SET_VOLUME: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            float leftVolume = data.readFloat();
            float rightVolume = data.readFloat();
            reply->writeInt32(setVolume(leftVolume, rightVolume));
            return NO_ERROR;
        } break;
        case INVOKE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            status_t result = invoke(data, reply);
            return result;
        } break;
        case SET_METADATA_FILTER: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setMetadataFilter(data));
            return NO_ERROR;
        } break;
        case GET_METADATA: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            bool update_only = static_cast<bool>(data.readInt32());
            bool apply_filter = static_cast<bool>(data.readInt32());
            const status_t retcode = getMetadata(update_only, apply_filter, reply);
            reply->setDataPosition(0);
            reply->writeInt32(retcode);
            reply->setDataPosition(0);
            return NO_ERROR;
        } break;
        case SET_AUX_EFFECT_SEND_LEVEL: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setAuxEffectSendLevel(data.readFloat()));
            return NO_ERROR;
        } break;
        case ATTACH_AUX_EFFECT: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(attachAuxEffect(data.readInt32()));
            return NO_ERROR;
        } break;
        case SET_PARAMETER: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            int key = data.readInt32();

            Parcel request;
            if (data.dataAvail() > 0) {
                request.appendFrom(
                        const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail());
            }
            request.setDataPosition(0);
            reply->writeInt32(setParameter(key, request));
            return NO_ERROR;
        } break;
        case GET_PARAMETER: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            return getParameter(data.readInt32(), reply);
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}