Esempio n. 1
0
// ----------------------------------------------------------------------------
void ofFmodSoundPlayer::play(){

	// if it's a looping sound, we should try to kill it, no?
	// or else people will have orphan channels that are looping
	if (bLoop == true){
		FMOD_Channel_Stop(channel);
	}

	// if the sound is not set to multiplay, then stop the current,
	// before we start another
	if (!bMultiPlay){
		FMOD_Channel_Stop(channel);
	}

	FMOD_System_PlaySound(sys, FMOD_CHANNEL_FREE, sound, bPaused, &channel);

	FMOD_Channel_GetFrequency(channel, &internalFreq);
	FMOD_Channel_SetVolume(channel,volume);
	setPan(pan);
	FMOD_Channel_SetFrequency(channel, internalFreq * speed);
	FMOD_Channel_SetMode(channel,  (bLoop == true) ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);

	//fmod update() should be called every frame - according to the docs.
	//we have been using fmod without calling it at all which resulted in channels not being able
	//to be reused.  we should have some sort of global update function but putting it here
	//solves the channel bug
	FMOD_System_Update(sys);

}
Esempio n. 2
0
bool Part::setProperty(P_ID id, const QVariant& property)
      {
      switch (id) {
            case P_ID::VISIBLE:
                  setShow(property.toBool());
                  break;
            case P_ID::USE_DRUMSET:
                  instrument()->setUseDrumset(property.toBool());
                  break;
            case P_ID::PART_VOLUME:
                  setVolume(property.toInt());
                  break;
            case P_ID::PART_MUTE:
                  setMute(property.toBool());
                  break;
            case P_ID::PART_PAN:
                  setPan(property.toInt());
                  break;
            case P_ID::PART_REVERB:
                  setReverb(property.toInt());
                  break;
            case P_ID::PART_CHORUS:
                  setChorus(property.toInt());
                  break;
            default:
                  qDebug("Part::setProperty: unknown id %d", int(id));
                  break;
            }
      score()->setLayoutAll();
      return true;
      }
void ofxOpenALSoundPlayer::updateInternalsForNewPrime() {
	setPitch(pitch);
	setLocation(location.x, location.y, location.z);
	setPan(pan);
	setVolume(volume);
	setLoop(bLoop);
}
Esempio n. 4
0
unsigned long RADAR::ping(int pan, int tilt)
{
  setPan(pan);
  setTilt(tilt);
  while (!ready());
  return ping();
}
//------------------------------------------------------------
void ofOpenALSoundPlayer::setVolume(float vol){
	volume = vol;
	if(sources.empty()) return;
	if(channels==1){
		alSourcef (sources[sources.size()-1], AL_GAIN, vol);
	}else{
		setPan(pan);
	}
}
Esempio n. 6
0
//---------------------------------------------------
void initDrumVoice()
{
	ampSmoothValue = 0.1f;

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

		SnapEg_init(&voiceArray[i].snapEg);
		setPan(i,0.f);
		voiceArray[i].vol = 0.8f;
		//voiceArray[i].panModifier = 1.f;
		voiceArray[i].fmModAmount = 0.5f;
		transient_init(&voiceArray[i].transGen);
#if ENABLE_DRUM_SVF
		SVF_init(&voiceArray[i].filter);
		voiceArray[i].filterType = 0x01;
#endif
		lfo_init(&voiceArray[i].lfo);

		voiceArray[i].modOsc.freq = 440;
		voiceArray[i].modOsc.waveform = 1;
		voiceArray[i].modOsc.fmMod = 0;
		voiceArray[i].modOsc.midiFreq = 70<<8;
		voiceArray[i].modOsc.pitchMod = 1.0f;
		voiceArray[i].modOsc.modNodeValue = 1;

		voiceArray[i].volumeMod = 1;

		voiceArray[i].osc.freq = 440;
		voiceArray[i].osc.modNodeValue = 1;
		voiceArray[i].osc.waveform = TRI+i; //for testing init to tri,saw,rec
		voiceArray[i].osc.fmMod = 0;
		voiceArray[i].osc.midiFreq = 70<<8;

		DecayEg_init(&voiceArray[i].oscPitchEg);
		voiceArray[i].egPitchModAmount = 0.5f;

		slopeEg2_init(&voiceArray[i].oscVolEg);
		setDistortionShape(&voiceArray[i].distortion, 2.f);

#ifdef USE_AMP_FILTER
		initOnePole(&voiceArray[i].ampFilter);
		setOnePoleCoef(&voiceArray[i].ampFilter,ampSmoothValue);
#endif

#if ENABLE_MIX_OSC
		voiceArray[i].mixOscs = true;
#endif
		voiceArray[i].decimationCnt = 0;
		voiceArray[i].decimationRate = 1;

	}
}
Esempio n. 7
0
void StatusManager::setFreePen(FunctionStatus s)
{
    stylus_group_.setStatus(ID_FREE_PEN, s);
    if (s == FUNC_SELECTED)
    {
        notify(ID_FREE_PEN);
    }
    else
    {
        setPan(FUNC_SELECTED);
    }
}
Esempio n. 8
0
void StatusManager::setSlideShow(FunctionStatus s)
{
    reading_tools_group_.setStatus(ID_SLIDE_SHOW, s);
    if (s == FUNC_SELECTED)
    {
        notify(ID_SLIDE_SHOW);
    }
    else
    {
        setPan(FUNC_SELECTED);
    }
}
void doTheThing(void)
{
	gbuff.add(gdnorm);
	gloveData_t gav = gbuff.average();
	switch(cMode){
		case rotate:
			x = lx+((gav.handGyX/32768.0f)-sx);
			y = ly+((gav.handGyY/32768.0f)-sy);
			z = lz+((gav.handGyZ/32768.0f)-sz);
			setRotation(y,x,z);
			break;
		case zoom:
			{gloveData_t gdiff1 = gdiff - gdnorm;
			int finger1Tense;
			finger1Tense = (gdiff1.fing1 <= 0 + gdiff.fing1*GLOVETOLERANCE) ? 1 : 0;
			int finger2Tense;
			finger2Tense = (gdiff1.fing2 <= 0 + gdiff.fing2*GLOVETOLERANCE) ? 1 : 0;
			setZoom((float)finger2Tense-finger1Tense);}
			break;
		case move:
			px = lpx+((gdnorm.handGyX/32768.0f)-spx);
			py = lpy+((gdnorm.handGyY/32768.0f)-spy);
			pz = lpz+((gdnorm.handGyZ/32768.0f)-spz);
			if(px > py && px > pz){
				setPan(px,0.0f,0.0f);
			}
			else if(py > px && py > pz){
				setPan(0.0f,py,0.0f);
			}
			else if(pz > px && pz > py)
			{
				setPan(0.0f,0.0f,pz);
			}
//			setPan(px,py,pz);
			//printData(gd);
			break;
		default:
		break;
	}
}
Esempio n. 10
0
void StatusManager::setErasing(FunctionStatus s)
{
    stylus_group_.setStatus(ID_ERASING, s);
    if (s == FUNC_SELECTED)
    {
        resetAnnotationGroup();
        notify(ID_ERASING);
    }
    else
    {
        setPan(FUNC_SELECTED);
    }
}
Esempio n. 11
0
aalError DSoundSource::init() {
	
	setVolume(channel.volume);
	setPitch(channel.pitch);
	
	// Create 3D interface if required
	if(channel.flags & FLAG_ANY_3D_FX) {
		
		if(sample->getFormat().channels != 1) {
			// TODO(broken-assets) newer DSound versions don't supprt this
		}
		
		if(lpdsb->QueryInterface(IID_IDirectSound3DBuffer, (void **)&lpds3db)) {
			return AAL_ERROR_SYSTEM;
		}
		
		if(channel.flags & FLAG_RELATIVE && lpds3db->SetMode(DS3DMODE_HEADRELATIVE, DS3D_DEFERRED)) {
			return AAL_ERROR_SYSTEM;
		}
		
		setPosition(channel.position);
		setVelocity(channel.velocity);
		setDirection(channel.direction);
		setCone(channel.cone);
		setFalloff(channel.falloff);
		
		if(backend->hasEAX) {
			
			lpds3db->QueryInterface(IID_IKsPropertySet, (void **)&lpeax);
			
			s32 value = 0;
			lpeax->Set(DSPROPSETID_EAX_BufferProperties,
			           DSPROPERTY_EAXBUFFER_FLAGS | DSPROPERTY_EAXBUFFER_DEFERRED,
			           NULL, 0, &value, sizeof(s32));
			
			if(!backend->environment || !(channel.flags & FLAG_REVERBERATION)) {
				value = -10000;
				lpeax->Set(DSPROPSETID_EAX_BufferProperties,
				           DSPROPERTY_EAXBUFFER_ROOM | DSPROPERTY_EAXBUFFER_DEFERRED,
				           NULL, 0, &value, sizeof(s32));
				lpeax->Set(DSPROPSETID_EAX_BufferProperties,
				           DSPROPERTY_EAXBUFFER_ROOMHF | DSPROPERTY_EAXBUFFER_DEFERRED,
				           NULL, 0, &value, sizeof(s32));
			}
		}
	} else {
		setPan(channel.pan);
	}
	
	return AAL_OK;
}
Esempio n. 12
0
void StatusManager::setDeleteAnnotation(FunctionStatus s)
{
    annotation_group_.setStatus(ID_DELETE_ANNOTATION, s);
    if (s == FUNC_SELECTED)
    {
        stylus_group_.setStatus(ID_DELETE_ANNOTATION, s);
        notify(ID_DELETE_ANNOTATION);
    }
    else
    {
        annotation_group_.setStatus(ID_ADD_ANNOTATION, FUNC_NORMAL);
        setPan(FUNC_SELECTED);
    }
}
Esempio n. 13
0
void StatusManager::setZoomIn(FunctionStatus s)
{
    stylus_group_.setStatus(ID_ZOOM_IN, s);
    zooming_group_.setStatus(ID_ZOOM_IN, s);
    if (s == FUNC_SELECTED)
    {
        resetAnnotationGroup();
        notify(ID_ZOOM_IN);
    }
    else
    {
        setPan(FUNC_SELECTED);
    }
}
Esempio n. 14
0
void PTUInterface::parseResponse(QByteArray barr){
	if(barr.size() < 1)
		return;

	int n;
	double m;
	switch(barr[0]){
	case 8: // change level word
		if(barr.size() < 6)
			break;
		n = barr.at(3) * 256 + barr.at(4);
		if(barr.at(2) == 5){ // pan
			m = 1.0 + n * 358.0 / 65535.0; // remap to [1, 359] from [0, 65535]
			setPan(m);
		} else if(barr.at(2) == 6){ // tilt
			m = 90.0 + n * 180.0 / 65535.0; // remap to [90, 270] from [0, 65535]
			setTilt(m);
		}
		break;
	case 2: // change level byte
		if(barr.size() < 5)
			break;
		n = barr.at(3);
		if(barr.at(2) == 0){ // pan
			m = 1.0 + n * 358.0 / 256.0; // remap to [1, 359] from [0, 256]
			setPan(m);
		} else if(barr.at(2) == 1){ // tilt
			m = 90.0 + n * 180.0 / 256.0; // remap to [90, 270] from [0, 256]
			setTilt(m);
		}
		break;
	default:
		// do nothing, for now
		break;
	}
}
Esempio n. 15
0
	void Soloud::oscillatePan(handle aVoiceHandle, float aFrom, float aTo, time aTime)
	{
		if (aTime <= 0 || aTo == aFrom)
		{
			setPan(aVoiceHandle, aTo);
			return;
		}

		if (mLockMutexFunc) mLockMutexFunc(mMutex);
		int ch = getVoiceFromHandle(aVoiceHandle);
		if (ch == -1) 
		{
			if (mUnlockMutexFunc) mUnlockMutexFunc(mMutex);
			return;
		}
		mVoice[ch]->mPanFader.setLFO(aFrom, aTo, aTime, mVoice[ch]->mStreamTime);
		if (mUnlockMutexFunc) mUnlockMutexFunc(mMutex);
	}
Esempio n. 16
0
void SUBnoteParameters::defaults(void)
{
    PVolume = 96;
    setPan(PPanning = 64);
    PAmpVelocityScaleFunction = 90;
    Pfixedfreq = 0;
    PfixedfreqET = 0;
    Pnumstages = 2;
    Pbandwidth = 40;
    Phmagtype = 0;
    Pbwscale = 64;
    Pstereo = true;
    Pstart = 1;

    PDetune = 8192;
    PCoarseDetune = 0;
    PDetuneType = 1;
    PFreqEnvelopeEnabled = 0;
    PBandWidthEnvelopeEnabled = 0;

    POvertoneSpread.type = 0;
    POvertoneSpread.par1 = 0;
    POvertoneSpread.par2 = 0;
    POvertoneSpread.par3 = 0;
    updateFrequencyMultipliers();

    for (int n = 0; n < MAX_SUB_HARMONICS; ++n)
    {
        Phmag[n] = 0;
        Phrelbw[n] = 64;
    }
    Phmag[0] = 127;

    PGlobalFilterEnabled = 0;
    PGlobalFilterVelocityScale = 64;
    PGlobalFilterVelocityScaleFunction = 64;

    AmpEnvelope->defaults();
    FreqEnvelope->defaults();
    BandWidthEnvelope->defaults();
    GlobalFilter->defaults();
    GlobalFilterEnvelope->defaults();
}
Esempio n. 17
0
	void Soloud::fadePan(int aVoiceHandle, float aTo, float aTime)
	{
		float from = getPan(aVoiceHandle);
		if (aTime <= 0 || aTo == from)
		{
			setPan(aVoiceHandle, aTo);
			return;
		}

		if (mLockMutexFunc) mLockMutexFunc(mMutex);
		int ch = getVoiceFromHandle(aVoiceHandle);
		if (ch == -1) 
		{
			if (mUnlockMutexFunc) mUnlockMutexFunc(mMutex);
			return;
		}
		mVoice[ch]->mPanFader.set(from, aTo, aTime, mVoice[ch]->mStreamTime);
		if (mUnlockMutexFunc) mUnlockMutexFunc(mMutex);
	}
Esempio n. 18
0
void DS_SFX_Set(sfxbuffer_t* buf, int prop, float value)
{
    ALuint source;

    if(!buf) return;

    source = SRC(buf);

    switch(prop)
    {
    case SFXBP_VOLUME:
        alSourcef(source, AL_GAIN, value);
        break;

    case SFXBP_FREQUENCY: {
        unsigned int dw = (int) (buf->rate * value);
        if(dw != buf->freq) // Don't set redundantly.
        {
            buf->freq = dw;
            alSourcef(source, AL_PITCH, value);
        }
        break; }

    case SFXBP_PAN:
        setPan(source, value);
        break;

    case SFXBP_MIN_DISTANCE:
        alSourcef(source, AL_REFERENCE_DISTANCE, value / unitsPerMeter);
        break;

    case SFXBP_MAX_DISTANCE:
        alSourcef(source, AL_MAX_DISTANCE, value / unitsPerMeter);
        break;

    case SFXBP_RELATIVE_MODE:
        alSourcei(source, AL_SOURCE_RELATIVE, value ? AL_TRUE : AL_FALSE);
        break;

    default: break;
    }
}
Esempio n. 19
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. 20
0
void StereoSample::setMix(float _volume, float _pan, float _width) {
	setVolume(_volume);
	setPan(_pan);
	setWidth(_width);
}
Esempio n. 21
0
void IMuseDigital::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, int g, int h) {
	int soundId = b;
	int sub_cmd = c;

	if (!cmd)
		return;

	switch (cmd) {
	case 10: // ImuseStopAllSounds
		stopAllSounds();
		break;
	case 12: // ImuseSetParam
		switch (sub_cmd) {
		case 0x400: // select group volume
			selectVolumeGroup(soundId, d);
			break;
		case 0x500: // set priority
			setPriority(soundId, d);
			break;
		case 0x600: // set volume
			setVolume(soundId, d);
			break;
		case 0x700: // set pan
			setPan(soundId, d);
			break;
		default:
			warning("IMuseDigital::doCommand SetParam DEFAULT command %d", sub_cmd);
			break;
		}
		break;
	case 14: // ImuseFadeParam
		switch (sub_cmd) {
		case 0x600: // set volume fading
			if ((d != 0) && (e == 0))
				setVolume(soundId, d);
			else if ((d == 0) && (e == 0))
				stopSound(soundId);
			else
				setFade(soundId, d, e);
			break;
		default:
			warning("IMuseDigital::doCommand FadeParam DEFAULT sub command %d", sub_cmd);
			break;
		}
		break;
	case 25: // ImuseStartStream
		debug(3, "ImuseStartStream (%d, %d, %d)", soundId, c, d);
		break;
	case 26: // ImuseSwitchStream
		debug(3, "ImuseSwitchStream (%d, %d, %d, %d, %d)", soundId, c, d, e, f);
		break;
	case 0x1000: // ImuseSetState
		debug(5, "ImuseSetState (%d)", b);
		if ((_vm->_game.id == GID_DIG) && (_vm->_game.features & GF_DEMO)) {
			if (b == 1) {
				fadeOutMusic(200);
				startMusic(1, 127);
			} else {
				if (getSoundStatus(2) == 0) {
					fadeOutMusic(200);
					startMusic(2, 127);
				}
			}
		} else if ((_vm->_game.id == GID_CMI) && (_vm->_game.features & GF_DEMO)) {
			if (b == 2) {
				fadeOutMusic(108);
				startMusic("in1.imx", 1100, 0, 127);
			} else if (b == 4) {
				fadeOutMusic(108);
				startMusic("in2.imx", 1120, 0, 127);
			} else if (b == 8) {
				fadeOutMusic(108);
				startMusic("out1.imx", 1140, 0, 127);
			} else if (b == 9) {
				fadeOutMusic(108);
				startMusic("out2.imx", 1150, 0, 127);
			} else if (b == 16) {
				fadeOutMusic(108);
				startMusic("gun.imx", 1210, 0, 127);
			} else {
				fadeOutMusic(120);
			}
		} else if (_vm->_game.id == GID_DIG) {
			setDigMusicState(b);
		} else if (_vm->_game.id == GID_CMI) {
			setComiMusicState(b);
		} else if (_vm->_game.id == GID_FT) {
			setFtMusicState(b);
		}
		break;
	case 0x1001: // ImuseSetSequence
		debug(5, "ImuseSetSequence (%d)", b);
		if (_vm->_game.id == GID_DIG) {
			setDigMusicSequence(b);
		} else if (_vm->_game.id == GID_CMI) {
			setComiMusicSequence(b);
		} else if (_vm->_game.id == GID_FT) {
			setFtMusicSequence(b);
		}
		break;
	case 0x1002: // ImuseSetCuePoint
		debug(5, "ImuseSetCuePoint (%d)", b);
		if (_vm->_game.id == GID_FT) {
			setFtMusicCuePoint(b);
		}
		break;
	case 0x1003: // ImuseSetAttribute
		debug(5, "ImuseSetAttribute (%d, %d)", b, c);
		assert((_vm->_game.id == GID_DIG) || (_vm->_game.id == GID_FT));
		if (_vm->_game.id == GID_DIG) {
			_attributes[b] = c;
		}
		break;
	case 0x2000: // ImuseSetGroupSfxVolume
		break;
	case 0x2001: // ImuseSetGroupVoiceVolume
		break;
	case 0x2002: // ImuseSetGroupMusicVolume
		break;
	default:
		error("IMuseDigital::doCommand DEFAULT command %d", cmd);
	}
}
Esempio n. 22
0
value ocaml_pan (value a)
{
    int t = (int)Double_val(a);
    setPan (getChannel(), t);
    return Val_unit;
}
Esempio n. 23
0
void home()
{
    setPan(_homePan);
    setTilt(_homeTilt);
}
Esempio n. 24
0
void SUBnoteParameters::getfromXML(XMLwrapper *xml)
{
    Pnumstages=xml->getpar127("num_stages",Pnumstages);
    Phmagtype=xml->getpar127("harmonic_mag_type",Phmagtype);
    Pstart=xml->getpar127("start",Pstart);

    if (xml->enterbranch("HARMONICS")) {
        Phmag[0]=0;
        for (int i=0;i<MAX_SUB_HARMONICS;i++) {
            if (xml->enterbranch("HARMONIC",i)==0) continue;
            Phmag[i]=xml->getpar127("mag",Phmag[i]);
            Phrelbw[i]=xml->getpar127("relbw",Phrelbw[i]);
            xml->exitbranch();
        }
        xml->exitbranch();
    }

    if (xml->enterbranch("AMPLITUDE_PARAMETERS"))
    {
        int xpar = xml->getparbool("stereo", (Pstereo) ? 1 : 0);
        Pstereo = (xpar != 0) ? true : false;
        PVolume=xml->getpar127("volume",PVolume);
        setPan(xml->getpar127("panning",PPanning));
        PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",PAmpVelocityScaleFunction);
        if (xml->enterbranch("AMPLITUDE_ENVELOPE")) {
            AmpEnvelope->getfromXML(xml);
            xml->exitbranch();
        }
        xml->exitbranch();
    }

    if (xml->enterbranch("FREQUENCY_PARAMETERS")) {
        Pfixedfreq=xml->getparbool("fixed_freq",Pfixedfreq);
        PfixedfreqET=xml->getpar127("fixed_freq_et",PfixedfreqET);

        PDetune=xml->getpar("detune",PDetune,0,16383);
        PCoarseDetune=xml->getpar("coarse_detune",PCoarseDetune,0,16383);
        POvertoneSpread.type =
            xml->getpar127("overtone_spread_type", POvertoneSpread.type);
        POvertoneSpread.par1 =
            xml->getpar("overtone_spread_par1", POvertoneSpread.par1, 0, 255);
        POvertoneSpread.par2 =
            xml->getpar("overtone_spread_par2", POvertoneSpread.par2, 0, 255);
        POvertoneSpread.par3 =
            xml->getpar("overtone_spread_par3", POvertoneSpread.par3, 0, 255);
        updateFrequencyMultipliers();
        PDetuneType=xml->getpar127("detune_type",PDetuneType);

        Pbandwidth=xml->getpar127("bandwidth",Pbandwidth);
        Pbwscale=xml->getpar127("bandwidth_scale",Pbwscale);

        PFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",PFreqEnvelopeEnabled);
        if (xml->enterbranch("FREQUENCY_ENVELOPE")) {
            FreqEnvelope->getfromXML(xml);
            xml->exitbranch();
        }

        PBandWidthEnvelopeEnabled=xml->getparbool("band_width_envelope_enabled",PBandWidthEnvelopeEnabled);
        if (xml->enterbranch("BANDWIDTH_ENVELOPE")) {
            BandWidthEnvelope->getfromXML(xml);
            xml->exitbranch();
        }
        xml->exitbranch();
    }

    if (xml->enterbranch("FILTER_PARAMETERS")) {
        PGlobalFilterEnabled=xml->getparbool("enabled",PGlobalFilterEnabled);
        if (xml->enterbranch("FILTER")) {
            GlobalFilter->getfromXML(xml);
            xml->exitbranch();
        }

        PGlobalFilterVelocityScaleFunction=xml->getpar127("filter_velocity_sensing",PGlobalFilterVelocityScaleFunction);
        PGlobalFilterVelocityScale=xml->getpar127("filter_velocity_sensing_amplitude",PGlobalFilterVelocityScale);

        if (xml->enterbranch("FILTER_ENVELOPE")) {
            GlobalFilterEnvelope->getfromXML(xml);
            xml->exitbranch();
        }
        xml->exitbranch();
    }
}
Esempio n. 25
0
//--------------------------------------------------------------
void testApp::draw() {
	
	ofSetColor(255, 255, 255);
	
		// draw from the live kinect
    //kinect.drawDepth(10, 10, 400, 300);
    //kinect.draw(420, 10, 400, 300);
		
    grayImage.draw(10, 10);
        
    ofNoFill();
    
        for(int i = 0; i < contourFinder.nBlobs; i++) {
            
            ofxCvBlob* blob;
            blob = &contourFinder.blobs.at(i);
            
            ofRectangle r = blob->boundingRect;
            r.x += 10; r.y += 10;
            
            ofSetLineWidth(1);
            ofSetColor(200);
            
            if (blob == trackedBlob) {
                ofSetLineWidth(3);
                ofSetColor(255);
            }
            
            ofRect(r);
        }
    
    

    
    if (trackedBlob) {
        
        
        int x = ofMap(trackedBlob->centroid.x - 70, 0, 600, 150, 0);
        int y = 5;
        int z = ofMap(trackedBlob->centroid.y, 250, 400, -30, 12);
      //int z = 20;
        //cout << trackedBlob->centroid.y << endl;
        
        
      /*
        int x = mouseX- 320;
        int y = mouseY - 240;
        int z = 400;
        */
        
        /*
        int x = mouseX - 320;
        int y = 0;
        int z = mouseY-300;*/
        
         
        if (x != 0) {
            
            ofVec3f vec = ofVec3f(x,y,z);
            
            ofVec3f lamp = ofVec3f(0,-200,0);
            
            vec = vec-lamp;
           // vec.normalize();
            
            float panAngle = atan2(vec.z, vec.x);
            float tiltAngle = asin(vec.y/vec.length());
            
           // cout<<tiltAngle<<endl;
            tiltAngle = HALF_PI - (tiltAngle - HALF_PI);
            panAngle += PI;
            //cout<<panAngle<<endl;
            //panAngle += PI;
            
            ofPushMatrix();
            ofTranslate(50, 50);
            ofRotate(panAngle * RAD_TO_DEG, 0, 0, 1);
            ofRect(0, 0, 100, 10);
            ofPopMatrix();

            ofPushMatrix();
            ofTranslate(50, 150);
            ofRotate(tiltAngle * RAD_TO_DEG, 0, 0, 1);
            ofRect(0, 0, 100, 10);
            ofPopMatrix();
            
            pan = ofMap(panAngle, 0, TWO_PI, 0, 255); 
            tilt = ofMap(tiltAngle, 0, PI, 30, 255-30);
            
            //printf("%i, %i pan: %f tilt: %f\n", pan, tilt, atan2(z, x),acos(y/vec.length()));
            
            /*vec_set(temp, your.x)
             vec_sub(temp, my.x)
             vec_to_angle(my.pan, temp)*/
            
            /*
            pan = ofMap(mouseX, 0, ofGetWidth(), 0, 255);
            tilt = ofMap(mouseY, 0, ofGetHeight(), 0, 255);
            cout<<tilt<<endl;*/
            //tilt = ofMap
            
            //pan = 63;
            //tilt = 255;
            
            setPan();
            setTilt();
            
        }
    }
    
    
    
    
    //contourFinder.draw(10, 320, 400, 300);
		
#ifdef USE_TWO_KINECTS
		kinect2.draw(420, 320, 400, 300);
#endif
	
	
	// draw instructions
    
    stringstream reportStream;
    
    
	ofSetColor(255, 255, 255);
        
    reportStream << "Pan:" << pan << ", tilt: " << tilt << endl;  
        
    if (trackedBlob) {
        
	reportStream << "Tracking blob at x: " << trackedBlob->centroid.x << " y: " << trackedBlob->centroid.y << "accel is: " << ofToString(kinect.getMksAccel().x, 2) << " / "
	<< ofToString(kinect.getMksAccel().y, 2) << " / "
	<< ofToString(kinect.getMksAccel().z, 2) << endl
	<< "using opencv threshold = " << bThreshWithOpenCV <<" (press spacebar)" << endl
	<< "set near threshold " << nearThreshold << " (press: + -)" << endl
	<< "set far threshold " << farThreshold << " (press: < >) num blobs found " << contourFinder.nBlobs
	<< ", fps: " << ofGetFrameRate() << endl
	<< "press c to close the connection and o to open it again, connection is: " << kinect.isConnected() << endl
	<< "press UP and DOWN to change the tilt angle: " << angle << " degrees" << endl;
	
    }
        
    ofDrawBitmapString(reportStream.str(),20,652);
        
}
 MonoToStereoPanner_::MonoToStereoPanner_(){
   setIsStereoOutput(true);
   panFrames.resize(kSynthesisBlockSize, 1);
   setPan(ControlValue(0));
 }
Esempio n. 27
0
//--------------------------------------------------------------
void testApp::keyPressed (int key) {
	switch (key) {  
		case ' ':
			bThreshWithOpenCV = !bThreshWithOpenCV;
			break;
			
		case '>':
		case '.':
			farThreshold ++;
			if (farThreshold > 255) farThreshold = 255;
			break;
			
		case '<':
		case ',':
			farThreshold --;
			if (farThreshold < 0) farThreshold = 0;
			break;
			
		case '+':
		case '=':
			nearThreshold ++;
			if (nearThreshold > 255) nearThreshold = 255;
			break;
			
		case '-':
			nearThreshold --;
			if (nearThreshold < 0) nearThreshold = 0;
			break;
			
		case 'w':
			kinect.enableDepthNearValueWhite(!kinect.isDepthNearValueWhite());
			break;
			
		case 'o':
			kinect.setCameraTiltAngle(angle); // go back to prev tilt
			kinect.open();
			break;
			
		case 'c':
			kinect.setCameraTiltAngle(0); // zero the tilt
			kinect.close();
			break;
			
		case OF_KEY_UP:
            
            focus += 1;
            setFocus();

			break;
			
		case OF_KEY_DOWN:
            focus -= 1;
            setFocus();
			break;
            
        case OF_KEY_LEFT:
            pan += 1;
            setPan();
            
			break;
			
		case OF_KEY_RIGHT:
            pan -= 1;
            setPan();
			break;
	}
}