public RESULT getRotation (out VECTOR forward, out VECTOR up) { return FMOD_Geometry_GetRotation(rawPtr, out forward, out up); }
private static extern RESULT FMOD_System_Set3DListenerAttributes(IntPtr system, int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up);
public RESULT set3DListenerAttributes(int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up) { return FMOD_System_Set3DListenerAttributes(systemraw, listener, ref pos, ref vel, ref forward, ref up); }
public RESULT getPosition (out VECTOR position) { return FMOD_Geometry_GetPosition(rawPtr, out position); }
private static extern RESULT FMOD_System_GetGeometryOcclusion(IntPtr system, ref VECTOR listener, ref VECTOR source, ref float direct, ref float reverb);
private static extern RESULT FMOD_Sound_Set3DCustomRolloff(IntPtr sound, ref VECTOR points, int numpoints);
public RESULT getGeometryOcclusion(ref VECTOR listener, ref VECTOR source, ref float direct, ref float reverb) { return FMOD_System_GetGeometryOcclusion(systemraw, ref listener, ref source, ref direct, ref reverb); }
private static extern RESULT FMOD_Reverb_Set3DAttributes(IntPtr reverb, ref VECTOR position, float mindistance, float maxdistance);
public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) { return FMOD_Sound_Set3DCustomRolloff(soundraw, ref points, numpoints); }
public RESULT get3DAttributes(ref VECTOR position, ref float mindistance, ref float maxdistance) { return FMOD_Reverb_Get3DAttributes(reverbraw, ref position, ref mindistance, ref maxdistance); }
// Reverb manipulation. public RESULT set3DAttributes(ref VECTOR position, float mindistance, float maxdistance) { return FMOD_Reverb_Set3DAttributes(reverbraw, ref position, mindistance, maxdistance); }
private static extern RESULT FMOD_Geometry_SetRotation(IntPtr geometry, ref VECTOR forward, ref VECTOR up);
private static extern RESULT FMOD_Geometry_SetScale(IntPtr geometry, ref VECTOR scale);
private static extern RESULT FMOD_Geometry_SetPolygonVertex(IntPtr geometry, int index, int vertexindex, ref VECTOR vertex);
private static extern RESULT FMOD_Geometry_AddPolygon(IntPtr geometry, float directocclusion, float reverbocclusion, int doublesided, int numvertices, VECTOR[] vertices, ref int polygonindex);
private static extern RESULT FMOD_Channel_Set3DConeOrientation(IntPtr channel, ref VECTOR orientation);
private static extern RESULT FMOD_ChannelGroup_Override3DAttributes(IntPtr channelgroup, ref VECTOR pos, ref VECTOR vel);
private static extern RESULT FMOD_Channel_Set3DCustomRolloff(IntPtr channel, ref VECTOR points, int numpoints);
public RESULT addPolygon(float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, ref int polygonindex) { return FMOD_Geometry_AddPolygon(geometryraw, directocclusion, reverbocclusion, (doublesided ? 1 : 0), numvertices, vertices, ref polygonindex); }
private static extern RESULT FMOD_Geometry_SetPosition(IntPtr geometry, ref VECTOR position);
public RESULT setPolygonVertex(int index, int vertexindex, ref VECTOR vertex) { return FMOD_Geometry_SetPolygonVertex(geometryraw, index, vertexindex, ref vertex); }
public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel) { return FMOD_Channel_Set3DAttributes(channelraw, ref pos, ref vel); }
public RESULT setPosition(ref VECTOR position) { return FMOD_Geometry_SetPosition(geometryraw, ref position); }
public RESULT override3DAttributes(ref VECTOR pos, ref VECTOR vel) { return FMOD_ChannelGroup_Override3DAttributes(channelgroupraw, ref pos, ref vel); }
public RESULT getScale (out VECTOR scale) { return FMOD_Geometry_GetScale(rawPtr, out scale); }
public RESULT setRotation(ref VECTOR forward, ref VECTOR up) { return FMOD_Geometry_SetRotation(geometryraw, ref forward, ref up); }
public RESULT set3DConeOrientation(ref VECTOR orientation) { return FMOD_Channel_Set3DConeOrientation(channelraw, ref orientation); }
public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) { return FMOD_Channel_Set3DCustomRolloff(channelraw, ref points, numpoints); }
public RESULT setScale(ref VECTOR scale) { return FMOD_Geometry_SetScale(geometryraw, ref scale); }
private static extern RESULT FMOD_Channel_Set3DAttributes(IntPtr channel, ref VECTOR pos, ref VECTOR vel);
void Update() { FMOD.VECTOR pos = FMODUtils.Vector3ToFMOD(transform.position); FMOD.VECTOR vel = FMODUtils.Vector3ToFMOD(Vector3.zero); // Only needed if we use doppler effect. FMOD.VECTOR alt_pan_pos = FMODUtils.Vector3ToFMOD(Vector3.zero); // FIXME: I do not know what this is. if (Volume < 0) { Volume = 0; } if (Speed < 0) { Speed = 0; } if (Channel != null) { Channel.set3DAttributes(ref pos, ref vel, ref alt_pan_pos); Channel.setVolume(Volume); Channel.setMute(Mute); SetSpeed(Speed); } }
// Start is called before the first frame update void Start() { SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetSoundSystem().createGeometry(1, 4, out _geometry)); // Cogemos la rotación y la posición FMOD.VECTOR position = FMODUnity.RuntimeUtils.ToFMODVector(gameObject.transform.position); FMOD.VECTOR forward = FMODUnity.RuntimeUtils.ToFMODVector(gameObject.transform.forward); FMOD.VECTOR up = FMODUnity.RuntimeUtils.ToFMODVector(gameObject.transform.up); //Ponemos la pared en la posición y mirando hacia donde mira el gameobject _geometry.setPosition(ref position); _geometry.setRotation(ref forward, ref up); Vector3 size = gameObject.transform.localScale; FMOD.VECTOR[] vertices = new FMOD.VECTOR[4]; vertices[0].x = ((-size.x / 2)); vertices[0].y = (size.y); vertices[0].z = 0; vertices[1].x = ((size.x / 2)); vertices[1].y = (size.y); vertices[1].z = 0; vertices[2].x = ((size.x / 2)); vertices[2].y = (-size.y); vertices[2].z = 0; vertices[3].x = ((-size.x / 2)); vertices[3].y = (-size.y); vertices[3].z = 0; SoundSystem.instance.ErrorCheck(_geometry.addPolygon(directOcclusion, reverbOcclusion, true, 4, vertices, out _polygonIndex)); }
void Update() { channel.setPaused(true); FMOD.VECTOR pos1 = new FMOD.VECTOR(); pos1.x = gameObject.transform.position.x; pos1.y = gameObject.transform.position.y; pos1.z = gameObject.transform.position.z; FMOD.VECTOR vel1 = new FMOD.VECTOR(); FMOD.VECTOR v2 = new FMOD.VECTOR(); v2.x = 0.0f; v2.y = 0.0f; v2.z = 0.0f; vel1.x = pos1.x - lastPos.x; vel1.y = pos1.y - lastPos.y; vel1.z = pos1.z - lastPos.z; lastPos = pos1; //UnityEngine.Debug.Log(etab); double myFreq = frequency; myFreq += frequency * etab[0] + frequency * etab[1]; myFreq = (myFreq % 1000.0f) + 80.0f; sine.setParameterFloat(1, (float)myFreq); sine.setParameterInt(0, (int)((Math.Round(5 * etab[0]) + offsetWave)) % 5); channel.set3DMinMaxDistance(minDist * DISTANCEFACTOR, maxDist * DISTANCEFACTOR); channel.set3DAttributes(ref pos1, ref vel1, ref vel1); channel.setVolume(0.4f * etab[2]); channel.setPaused(false); //lowlevel.update(); }
private IEnumerator WaitForStreamBuffer() { do { yield return(null); } while (state == FMOD.OPENSTATE.CONNECTING || state == FMOD.OPENSTATE.BUFFERING); if (state == FMOD.OPENSTATE.READY) { Debug.Log("Internet stream loaded"); radioStream.setMode(FMOD.MODE.OPENUSER | FMOD.MODE._3D | FMOD.MODE._3D_LINEARROLLOFF); lowLevelSystem.playSound(radioStream, channelGroup, true, out channel); FMOD.ATTRIBUTES_3D attributes = FMODUnity.RuntimeUtils.To3DAttributes(gameObject); FMOD.VECTOR alt_pan_pos = Vector3.zero.ToFMODVector(); channel.set3DMinMaxDistance(minDistance, maxDistance); channel.setLoopCount(-1); channel.setMode(FMOD.MODE.LOOP_NORMAL); channel.set3DAttributes(ref attributes.position, ref attributes.velocity, ref alt_pan_pos); channel.setPaused(false); channel.setVolume(volume); isReadyAndPlaying = true; } else if (state == FMOD.OPENSTATE.ERROR) { Debug.Log("Error while loading online , check the address or connection"); } }
void Update() { attributes.forward = FMODUnity.RuntimeUtils.ToFMODVector(cam.forward); attributes.up = FMODUnity.RuntimeUtils.ToFMODVector(cam.up); attributes.position = FMODUnity.RuntimeUtils.ToFMODVector(cam.position); playerPosition = FMODUnity.RuntimeUtils.ToFMODVector(player.position); FMODUnity.RuntimeManager.StudioSystem.setListenerAttributes(listener, attributes, playerPosition); }
/// <summary> /// Convert OpenMetaVerse to FMOD coordinate space. /// </summary> /// <param name="omvV"></param> /// <returns></returns> protected FMOD.VECTOR FromOMVSpace(OpenMetaverse.Vector3 omvV) { // OMV X is forward/East, Y is left/North, Z is up. // FMOD Z is forward/East, X is right/South, Y is up. FMOD.VECTOR v = new FMOD.VECTOR(); v.x = -omvV.Y; v.y = omvV.Z; v.z = omvV.X; return(v); }
// Update is called once per frame void Update() { // Cogemos la rotación y la posición FMOD.VECTOR position = FMODUnity.RuntimeUtils.ToFMODVector(gameObject.transform.position); FMOD.VECTOR forward = FMODUnity.RuntimeUtils.ToFMODVector(gameObject.transform.forward); FMOD.VECTOR up = FMODUnity.RuntimeUtils.ToFMODVector(gameObject.transform.up); //Ponemos la pared en la posición y mirando hacia donde mira el gameobject _geometry.setPosition(ref position); _geometry.setRotation(ref forward, ref up); }
public override void Update(GameTime gameTime) { base.Update(gameTime); FMOD.VECTOR pos = Engine.Sound.SoundPlayer.FMODVectorFromVector3(GetWorldLocation()); if (reverb != null) { reverb.set3DAttributes(ref pos, minDist, maxDist); } else { throw new System.NullReferenceException("Attempt to work with null reverb in reverb component"); } }
void Update() { if (_id != -1) { Quaternion rotation = transform.rotation; FMOD.VECTOR pos = FMODUtils.Vector3ToFMOD(transform.position); FMOD.VECTOR vel = FMODUtils.Vector3ToFMOD(Vector3.zero); // Only needed if we use doppler effect. FMOD.VECTOR forward = FMODUtils.Vector3ToFMOD(rotation * Vector3.forward); FMOD.VECTOR up = FMODUtils.Vector3ToFMOD(rotation * Vector3.up); _system.set3DListenerAttributes(_id, ref pos, ref vel, ref forward, ref up); } }
public void updateSystem(bool force3DSet) { FMOD.RESULT result = FMOD.RESULT.OK; if (m_eventSystem != null && m_eventSystemWasInit) { if (getAudioListener() != null && (force3DSet || (Time.timeSinceLevelLoad - m_previousListenerUpdateTime) > 0.001f)) { FMOD.VECTOR pos = new FMOD.VECTOR(); FMOD.VECTOR vel = new FMOD.VECTOR(); FMOD.VECTOR forward = new FMOD.VECTOR(); FMOD.VECTOR up = new FMOD.VECTOR(); pos.x = m_audioListener.transform.position.x; pos.y = m_audioListener.transform.position.y; pos.z = m_audioListener.transform.position.z; if (Time.timeSinceLevelLoad - m_previousListenerUpdateTime > 0) { vel.x = (pos.x - m_previousListenerPos.x) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime); vel.y = (pos.y - m_previousListenerPos.y) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime); vel.z = (pos.z - m_previousListenerPos.z) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime); } forward.x = m_audioListener.transform.forward.x; forward.y = m_audioListener.transform.forward.y; forward.z = m_audioListener.transform.forward.z; up.x = m_audioListener.transform.up.x; up.y = m_audioListener.transform.up.y; up.z = m_audioListener.transform.up.z; result = m_eventSystem.set3DListenerAttributes(0, ref pos, ref vel, ref forward, ref up); ERRCHECK(result); result = m_system.set3DListenerAttributes(0, ref pos, ref vel, ref forward, ref up); ERRCHECK(result); m_previousListenerPos = m_audioListener.transform.position; // m_previousListenerForward = m_audioListener.transform.forward; // m_previousListenerUp = m_audioListener.transform.up; m_previousListenerUpdateTime = Time.timeSinceLevelLoad; } result = m_eventSystem.update(); ERRCHECK(result); result = m_system.update(); ERRCHECK(result); } }
private string path = "Assets/3rdPerson+Fly/Sounds/"; // Path of the sound to listen void Start() { path = path + soundName; _channel = new Channel(); _channelGroup = new FMOD.ChannelGroup(); _alt_pan_pos = new FMOD.VECTOR(); _rigidBody = gameObject.GetComponent <Rigidbody>(); // Convert game object 3d attributes to FMOD.ATTRIBUTES_3D struct _attributes3D = RuntimeUtils.To3DAttributes(gameObject, _rigidBody); _soundManager.Create(path, FMOD.MODE.LOOP_NORMAL, out _sound); _soundManager.Play(_sound, _channelGroup, false, out _channel, _attributes3D.position, _attributes3D.velocity, _alt_pan_pos); _soundManager.ChangeVolume(volume); // minDistance: distancia a partir de la cual el sonido comienza a atenuarse // maxDistance: distancia a partir de la cual el sonido no se atenúa más (el volumen no es necesariamente 0.0) _channel.set3DMinMaxDistance(3.0f, 40.0f); }
// Use this for initialization void Start() { channel = new FMOD.Channel(); lowLevelSystem = FMODUnity.RuntimeManager.LowlevelSystem; FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup); lowLevelSystem.createSound("Assets\\Sounds\\guitar.mp3", FMOD.MODE.DEFAULT, out guitarSong); string songName = ""; guitarSong.getName(out songName, 20); Debug.Log("Playing song: " + songName, gameObject); guitarSong.setMode(FMOD.MODE.OPENUSER | FMOD.MODE._3D | FMOD.MODE._3D_LINEARSQUAREROLLOFF); lowLevelSystem.playSound(guitarSong, channelGroup, true, out channel); channel.set3DMinMaxDistance(minDistance, maxDistance); channel.setLoopCount(-1); channel.setMode(FMOD.MODE.LOOP_NORMAL); FMOD.ATTRIBUTES_3D attributes = FMODUnity.RuntimeUtils.To3DAttributes(gameObject); FMOD.VECTOR alt_pan_pos = Vector3.zero.ToFMODVector(); channel.set3DAttributes(ref attributes.position, ref attributes.velocity, ref alt_pan_pos); channel.setPaused(false); }
public void UpdateEvent(Vector3 curPos, float timeSinceLevelLoad) { if (m_runtimeEvent != null) { if (m_eventSystemHandle == null || m_eventSystemHandle.getEventSystem() == null || m_eventSystemHandle.getEventSystem().wasCleaned()) { return; } FMOD.RESULT result = FMOD.RESULT.OK; foreach (FmodRuntimeEventParameter p in getParameters()) { p.UpdateParam(timeSinceLevelLoad - m_previousUpdateTime); } if (m_source.getSourceType() == FmodEvent.SourceType.SOURCE_3D) { FMOD.VECTOR pos = new FMOD.VECTOR(); FMOD.VECTOR vel = new FMOD.VECTOR(); pos.x = curPos.x; pos.y = curPos.y; pos.z = curPos.z; if (timeSinceLevelLoad - m_previousUpdateTime > 0) { vel.x = (curPos.x - m_previousPos.x) / (timeSinceLevelLoad - m_previousUpdateTime); vel.y = (curPos.y - m_previousPos.y) / (timeSinceLevelLoad - m_previousUpdateTime); vel.z = (curPos.z - m_previousPos.z) / (timeSinceLevelLoad - m_previousUpdateTime); } m_previousPos = curPos; result = m_runtimeEvent.set3DAttributes(ref pos, ref vel); ERRCHECK(result); } m_previousUpdateTime = timeSinceLevelLoad; } }
private static extern RESULT FMOD5_Geometry_SetScale(IntPtr geometry, ref VECTOR scale);
/// <summary> /// Thread to update listener position and generally keep /// FMOD up to date. /// </summary> private void ListenerUpdate() { // Notice changes in position or direction. Vector3 lastpos = new Vector3(0.0f, 0.0f, 0.0f); float lastface = 0.0f; while (true) { // Two updates per second. Thread.Sleep(500); if (system == null) { continue; } var my = Instance.Client.Self; Vector3 newPosition = new Vector3(my.SimPosition); float newFace = my.SimRotation.W; // If we are standing still, nothing to update now, but // FMOD needs a 'tick' anyway for callbacks, etc. In looping // 'game' programs, the loop is the 'tick'. Since Radegast // uses events and has no loop, we use this position update // thread to drive the FMOD tick. Have to move more than // 500mm or turn more than 10 desgrees to bother with. // if (newPosition.ApproxEquals(lastpos, 0.5f) && Math.Abs(newFace - lastface) < 0.2) { invoke(new SoundDelegate(delegate { FMODExec(system.update()); })); continue; } // We have moved or turned. Remember new position. lastpos = newPosition; lastface = newFace; // Convert coordinate spaces. FMOD.VECTOR listenerpos = FromOMVSpace(newPosition); // Get azimuth from the facing Quaternion. Note we assume the // avatar is standing upright. Avatars in unusual positions // hear things from unpredictable directions. // By definition, facing.W = Cos( angle/2 ) // With angle=0 meaning East. double angle = 2.0 * Math.Acos(newFace); // Construct facing unit vector in FMOD coordinates. // Z is East, X is South, Y is up. FMOD.VECTOR forward = new FMOD.VECTOR { x = (float)Math.Sin(angle), y = 0.0f, z = (float)Math.Cos(angle) }; // South // East //Logger.Log( // String.Format( // "Standing at <{0:0.0},{1:0.0},{2:0.0}> facing {3:d}", // listenerpos.x, // listenerpos.y, // listenerpos.z, // (int)(angle * 180.0 / 3.141592)), // Helpers.LogLevel.Debug); // Tell FMOD the new orientation. invoke(new SoundDelegate(delegate { FMODExec(system.set3DListenerAttributes( 0, ref listenerpos, // Position ref ZeroVector, // Velocity ref forward, // Facing direction ref UpVector)); // Top of head FMODExec(system.update()); })); } }
void Start() { etab = ((botControl)gameObject.GetComponent <botControl>()).emoTab; FMOD.VECTOR pos1 = new FMOD.VECTOR(); pos1.x = gameObject.transform.position.x; pos1.y = gameObject.transform.position.y; pos1.z = gameObject.transform.position.z; lastPos = pos1; FMOD.VECTOR vel1 = new FMOD.VECTOR(); vel1.x = 0.0f; vel1.y = 0.0f; vel1.z = 0.0f; FMODUnity.RuntimeManager.StudioSystem.getLowLevelSystem(out lowlevel); System.Random random = new System.Random(); offsetWave = random.Next(0, 5); switch (random.Next(0, 5)) { case 0: { frequency = 220f; break; } case 1: { frequency = 440f; break; } case 2: { frequency = 880f; break; } case 3: { frequency = 1760f; break; } case 4: { frequency = 110f; break; } case 5: { frequency = 3520f; break; } default: { break; } } lowlevel.createDSPByType(DSP_TYPE.OSCILLATOR, out sine); sine.setParameterFloat(1, (float)frequency); lowlevel.playDSP(sine, null, true, out channel); channel.setMode(MODE._3D | MODE._3D_LINEARROLLOFF); channel.set3DMinMaxDistance(minDist * DISTANCEFACTOR, maxDist * DISTANCEFACTOR); channel.set3DAttributes(ref pos1, ref vel1, ref vel1); channel.setVolume(0.3f); channel.setPaused(false); }
// Update is called once per frame void Update () { FMOD.ATTRIBUTES_3D attributes = FMODUnity.RuntimeUtils.To3DAttributes(gameObject); alt_pan_pos = Vector3.zero.ToFMODVector(); channel.set3DAttributes(ref attributes.position, ref attributes.velocity, ref alt_pan_pos); }
public void Play(FMOD.Sound sound, FMOD.ChannelGroup channelGroup, bool paused, out FMOD.Channel channel, FMOD.VECTOR pos, FMOD.VECTOR vel, FMOD.VECTOR alt_pan_pos) { _soundSystem.playSound(sound, channelGroup, paused, out channel); _channel = channel; _channel.set3DAttributes(ref pos, ref vel, ref alt_pan_pos); }
private static extern RESULT FMOD5_Geometry_GetRotation(IntPtr geometry, out VECTOR forward, out VECTOR up);
private static extern RESULT FMOD5_Geometry_GetPosition(IntPtr geometry, out VECTOR position);
private static extern RESULT FMOD5_Geometry_GetPolygonVertex(IntPtr geometry, int index, int vertexindex, out VECTOR vertex);
private static extern RESULT FMOD5_System_Get3DListenerAttributes(IntPtr system, int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up);
public RESULT override3DAttributes(ref VECTOR pos, ref VECTOR vel) { return(ChannelGroup.FMOD_ChannelGroup_Override3DAttributes(channelgroupraw, ref pos, ref vel)); }
public RESULT get3DListenerAttributes(int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up) { return(FMOD5_System_Get3DListenerAttributes(handle, listener, out pos, out vel, out forward, out up)); }
private static extern RESULT FMOD5_System_GetGeometryOcclusion(IntPtr system, ref VECTOR listener, ref VECTOR source, out float direct, out float reverb);
private static extern RESULT FMOD5_ChannelGroup_Set3DCustomRolloff(IntPtr channelgroup, ref VECTOR points, int numpoints);
public RESULT getGeometryOcclusion(ref VECTOR listener, ref VECTOR source, out float direct, out float reverb) { return(FMOD5_System_GetGeometryOcclusion(handle, ref listener, ref source, out direct, out reverb)); }
private static extern RESULT FMOD5_ChannelGroup_Get3DConeOrientation(IntPtr channelgroup, out VECTOR orientation);
public RESULT set3DListenerAttributes(int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up) { return(FMOD5_System_Set3DListenerAttributes(handle, listener, ref pos, ref vel, ref forward, ref up)); }