Esempio n. 1
0
        public void Play(ISoundEngine engine)
        {
            Byte[] data = new Byte[this.length * 2]; // signed 16-bit

            for (Int32 i = 0; i < this.length; i++)
            {
                Int16 sample = (Int16)values[i];
                data[i * 2]       += (byte)(sample >> 8);
                data[(i * 2) + 1] += (byte)(sample & 0xFF);
                //writer.Write(sample);
            }

            engine.RemoveSoundSource(name);
            this.source = engine.AddSoundSourceFromPCMData(data, name, fmt);
            engine.Play2D(name, true);
        }
Esempio n. 2
0
        //called each frame by vvvv
        public void Evaluate(int SpreadMax)
        {
            bool ChangedSpreadSize = FPreviousSpreadMax == SpreadMax ? false : true;
            bool Reload            = false;

            if (FPlay.IsChanged || ChangedSpreadSize || FFile.IsChanged)
            {
                Reload = true;
            }

            FLength.SliceCount = SpreadMax;

            //tells the Irrklang engine which System Audio Output to use
            #region output devices

            if (FDeviceenum.IsChanged)
            {
                try
                {
                    int id = FDeviceSelect[FDeviceenum[0]];
                    FEngine.StopAllSounds();
                    FEngine = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions, FDevice.getDeviceID(id));
                    FEngine.LoadPlugins(Path.Combine(Environment.CurrentDirectory, "plugins"));
                    FDriverUse[0] = FEngine.Name;
                    FMultiT[0]    = FEngine.IsMultiThreaded;
                }
                catch (Exception ex)
                {
                    FLogger.Log(LogType.Error, ex.Message);
                }
            }

            #endregion output devices

            //Sets the MainVoume of the Engine
            #region MainVolume

            if (FMainVolume.IsChanged)
            {
                FEngine.SoundVolume = (float)FMainVolume[0];
            }

            #endregion MainVolume

            //Handles the Reading and Deleting of the Files
            //and Creating the ISoundSource Onject
            #region File IO
            if (FFile.IsChanged || ChangedSpreadSize)
            {
                FilePath.Clear();
                SoundSources.Clear();

                if (FLoadedFiles.Count < SpreadMax)
                {
                    int Diff = SpreadMax - FLoadedFiles.Count;
                    for (int i = FLoadedFiles.Count; i < SpreadMax; i++)
                    {
                        FLoadedFiles.Add("");
                    }
                }


                for (int i = 0; i < SpreadMax; i++)
                {
                    if (!String.IsNullOrEmpty(FFile[i]))
                    {
                        if (FLoadedFiles[i] != FFile[i])
                        {
                            if (FLoadedFiles.Contains(FFile[i]))
                            {
                                int          SourceIndex = FLoadedFiles.IndexOf(FFile[i]);
                                ISoundSource SoundSource;
                                FLoadedSourceFiles.TryGetValue(SourceIndex, out SoundSource);

                                string       FileName       = Path.Combine(Path.GetDirectoryName(FFile[i]), Path.GetFileNameWithoutExtension(FFile[i]) + "D" + i.ToString() + Path.GetExtension(FFile[i]));
                                ISoundSource NewSoundSource = FEngine.AddSoundSourceAlias(SoundSource, FileName);
                                SoundSources.Add(i, NewSoundSource);
                                FilePath.Add(FFile[i]);
                            }
                            else
                            {
                                if (FilePath.Contains(FFile[i]))
                                {
                                    int          SourceIndex = FilePath.IndexOf(FFile[i]);
                                    ISoundSource SoundSource;
                                    SoundSources.TryGetValue(SourceIndex, out SoundSource);

                                    string       FileName       = Path.Combine(Path.GetDirectoryName(FFile[i]), Path.GetFileNameWithoutExtension(FFile[i]) + "D" + i.ToString() + Path.GetExtension(FFile[i]));
                                    ISoundSource NewSoundSource = FEngine.AddSoundSourceAlias(SoundSource, FileName);
                                    SoundSources.Add(i, NewSoundSource);
                                    FilePath.Add(FFile[i]);
                                }
                                else
                                {
                                    ISoundSource SoundSource = FEngine.AddSoundSourceFromFile(FFile[i]);
                                    SoundSources.Add(i, SoundSource);
                                    FilePath.Add(FFile[i]);
                                }
                            }
                        }
                        else
                        {
                            ISoundSource SoundSource;
                            FLoadedSourceFiles.TryGetValue(i, out SoundSource);
                            SoundSources.Add(i, SoundSource);
                            FilePath.Add(FFile[i]);
                        }
                    }
                    else
                    {
                        SoundSources.Add(i, null);
                        FilePath.Add(FFile[i]);
                    }
                }

                DeleteList.Clear();

                if (FLoadedFiles.Count > SpreadMax)
                {
                    for (int i = FLoadedFiles.Count; i > SpreadMax; i--)
                    {
                        int          Index = i - 1;
                        ISoundSource SoundSource;
                        FLoadedSourceFiles.TryGetValue(Index, out SoundSource);
                        if (SoundSource != null)
                        {
                            DeleteList.Add(SoundSource.Name);
                        }
                    }
                }

                int LastFoundIndex = -1;
                foreach (string tFile in FLoadedFiles)
                {
                    if (FilePath.Contains(tFile) == false)
                    {
                        int Index = FLoadedFiles.IndexOf(tFile, LastFoundIndex + 1);
                        if (Index != -1)
                        {
                            ISoundSource SoundSource;
                            FLoadedSourceFiles.TryGetValue(Index, out SoundSource);
                            LastFoundIndex = Index;
                            if (SoundSource != null)
                            {
                                DeleteList.Add(SoundSource.Name);
                            }
                        }
                    }
                }


                foreach (string File in DeleteList)
                {
                    FEngine.RemoveSoundSource(File);
                }


                FLoadedSourceFiles = new Dictionary <int, ISoundSource>(SoundSources);
                FLoadedFiles       = new List <string>(FilePath);
            }



            #endregion FileIO

            //Start and stops the laoded files
            //if a file is started the ISound Object is created
            #region Start / Stop Sounds
            if (FPlay.IsChanged || Reload)
            {
                List <ISound> NewSounds = new List <ISound>();

                for (int i = 0; i < SpreadMax; i++)
                {
                    ISoundSource SoundSource;
                    FLoadedSourceFiles.TryGetValue(i, out SoundSource);
                    FLength[i] = (double)SoundSource.PlayLength / 1000;

                    //checks the Play pin
                    if (FPlay[i])
                    {
                        //Creates the sound onject every frame and adds it to the FSound List
                        //can not just played the sound at the given position or replayed
                        //after Position changed??


                        bool SoundActive = false;

                        try
                        {
                            if (FPlayedSounds[i] != null)
                            {
                                SoundActive = true;
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            SoundActive = false;
                        }

                        if (SoundSource != null)
                        {
                            if (SoundActive == false)
                            {
                                if (FPlayMode[0].Name == "3D")
                                {
                                    ISound Sound = FEngine.Play3D(SoundSource, (float)FSoundPosition[i].x, (float)FSoundPosition[i].y, (float)FSoundPosition[i].z, FLoop[i], false, true);
                                    Sound.setSoundStopEventReceiver(this);
                                    NewSounds.Add(Sound);
                                }
                                else
                                {
                                    ISound Sound = FEngine.Play2D(SoundSource, FLoop[i], false, true);
                                    Sound.setSoundStopEventReceiver(this);
                                    NewSounds.Add(Sound);
                                }
                            }
                            else
                            {
                                NewSounds.Add(FPlayedSounds[i]);
                            }
                        }
                        else
                        {
                            FLogger.Log(LogType.Error, "No SoundSource found");
                            NewSounds.Add(null);
                        }
                    }
                    else
                    {
                        try
                        {
                            if (FPlayedSounds[i] != null)
                            {
                                FPlayedSounds[i].Stop();
                                NewSounds.Add(null);
                            }
                            else
                            {
                                NewSounds.Add(null);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            NewSounds.Add(null);
                        }
                        catch (NullReferenceException)
                        {
                            NewSounds.Add(null);
                        }
                    }
                }
                FPlayedSounds = new List <ISound>(NewSounds);
            }

            #endregion Start / Stop Sounds

            //set the Loop Propertie of a ISound Object
            #region Loop

            if (FLoop.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        if (FLoop[i] == true)
                        {
                            FPlayedSounds[i].Looped = true;
                        }
                        else
                        {
                            FPlayedSounds[i].Looped = false;
                        }
                    }
                }
            }

            #endregion Loop

            //handles the seeking operation
            #region Seek

            if (FSeek.IsChanged)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        if (FSeek[i] == true)
                        {
                            FPlayedSounds[i].PlayPosition = (uint)(((UInt32)FSeekPos[i]) * 1000.0);
                        }
                    }
                }
            }

            #endregion Seek

            ////set the Pause Propertie of a ISound Object
            #region Pause

            if (FPause.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        if (FPause[i])
                        {
                            FPlayedSounds[i].Paused = true;
                        }
                        else
                        {
                            FPlayedSounds[i].Paused = false;
                        }
                    }
                }
            }

            #endregion Pause

            //set the PlaybackSpeed Propertie of a ISound Object
            #region Speed

            if (FPlaybackSpeed.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        FPlayedSounds[i].PlaybackSpeed = FPlaybackSpeed[i];
                    }
                }
            }


            #endregion Speed

            //stops or paused all SoundSource which are playedback with the Irrklangengine
            #region Stop / Pause All

            if (FStopAll.IsChanged)
            {
                if (FStopAll[0])
                {
                    FEngine.StopAllSounds();
                }
            }

            if (FPauseAll.IsChanged)
            {
                if (FPause[0])
                {
                    FEngine.SetAllSoundsPaused(true);
                }
                else
                {
                    FEngine.SetAllSoundsPaused(false);
                }
            }

            #endregion Stop / Pause All

            //sets the Volume Property of a ISound Object
            #region Volume

            if (FVolume.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        FPlayedSounds[i].Volume = FVolume[i];
                    }
                }
            }

            #endregion Volume

            //sets the Pan Property of a ISound Object, only works if the sound is plyed pack in 2D Mode
            #region Pan

            if (FPan.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null && FPlayMode[i].Name == "2D")
                    {
                        FPlayedSounds[i].Pan = FPan[i];
                    }
                }
            }

            #endregion Pan

            //Sets the Postion Property of a ISound Object, only works in the 3D Playback mode
            #region Position

            if (FSoundPosition.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        Vector3D          Vector    = FSoundPosition[i];
                        IrrKlang.Vector3D IrrVector = new IrrKlang.Vector3D((float)Vector.x, (float)Vector.y, (float)Vector.z);
                        FPlayedSounds[i].Position = IrrVector;
                    }
                }
            }

            #endregion Position

            //Sets the Velocity Property of a ISound Object, only works in the 3D Playback mode
            #region Sound Velocity

            if (FSoundVelocity.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        Vector3D          Vector    = FSoundVelocity[i];
                        IrrKlang.Vector3D IrrVector = new IrrKlang.Vector3D((float)Vector.x, (float)Vector.y, (float)Vector.z);
                        FPlayedSounds[i].Velocity = IrrVector;
                    }
                }
            }



            #endregion Sound Velocity

            //sets the MinDistance Propertie of a ISound Object
            #region MinDistance

            if (FMinDist.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        FPlayedSounds[i].MinDistance = FMinDist[i];
                    }
                }
            }

            #endregion MinDistance

            //sets the MaxDistance Propertie of a ISound Object
            #region MaxDistance

            if (FMaxDist.IsChanged || Reload)
            {
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FPlayedSounds[i] != null)
                    {
                        FPlayedSounds[i].MaxDistance = FMinDist[i];
                    }
                }
            }

            #endregion MaxDistance

            //set the Listener Position of the Engine
            #region View Listener

            if (FViewDir.IsChanged || FViewPos.IsChanged || FViewUpVector.IsChanged || FViewVelocity.IsChanged)
            {
                IrrKlang.Vector3D ViewDir      = new IrrKlang.Vector3D((float)FViewDir[0].x, (float)FViewDir[0].y, (float)FViewDir[0].z);
                IrrKlang.Vector3D ViewPos      = new IrrKlang.Vector3D((float)FViewPos[0].x, (float)FViewPos[0].y, (float)FViewPos[0].z);
                IrrKlang.Vector3D ViewVelocity = new IrrKlang.Vector3D((float)FViewVelocity[0].x, (float)FViewVelocity[0].y, (float)FViewVelocity[0].z);
                IrrKlang.Vector3D ViewUp       = new IrrKlang.Vector3D((float)FViewUpVector[0].x, (float)FViewUpVector[0].y, (float)FViewUpVector[0].z);

                FEngine.SetListenerPosition(ViewDir, ViewPos, ViewVelocity, ViewUp);
            }

            #endregion View Listener

            //sets the RollOff effekt of the Engine
            #region RollOff

            if (FRollOff.IsChanged)
            {
                FEngine.SetRolloffFactor(FRollOff[0]);
            }

            #endregion RollOFF

            //sets the DopllerEffekt of the Engine
            #region DopplerEffekt

            if (FDoplerFactor.IsChanged || FDoplerDistanceFactor.IsChanged)
            {
                FEngine.SetDopplerEffectParameters(FDoplerFactor[0], FDoplerDistanceFactor[0]);
            }

            #endregion DopplerEffekt

            #region Effekts

            if (FEnableEffekts[0] == true)
            {
                //Sets the Chorus Effekt of a ISound Object
                #region Chorus

                if (Reload || FEnableChorus.IsChanged || FChorusDelay.IsChanged || FChorusFrequency.IsChanged || FChoruspDepth.IsChanged || FChoruspFeedback.IsChanged || FChorusPhase.IsChanged || FChoruspWetDryMix.IsChanged || FChorusSinusWaveForm.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableChorus[i])
                            {
                                Fx.EnableChorusSoundEffect(FChoruspWetDryMix[i], FChoruspDepth[i], FChoruspFeedback[i], FChorusFrequency[i], FChorusSinusWaveForm[i], FChorusDelay[i], FChorusPhase[i]);
                            }
                            else
                            {
                                Fx.DisableChorusSoundEffect();
                            }
                        }
                    }
                }

                #endregion Chorus

                //Sets the Compresser Effekt of a ISound Object
                #region Compressor

                if (Reload || FEnableComp.IsChanged || FCompAttack.IsChanged || FCompGain.IsChanged || FCompPredelay.IsChanged || FCompRatio.IsChanged || FCompRelease.IsChanged || FCompThreshold.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableComp[i])
                            {
                                Fx.EnableCompressorSoundEffect(FCompGain[i], FCompAttack[i], FCompRelease[i], FCompThreshold[i], FCompRatio[i], FCompPredelay[i]);
                            }
                            else
                            {
                                Fx.DisableCompressorSoundEffect();
                            }
                        }
                    }
                }

                #endregion Compressor

                //Sets the Distortion Effekt of a ISound Object
                #region Disortion

                if (Reload || FEnableDistortion.IsChanged || FDistortionGain.IsChanged || FDistortionBandwidth.IsChanged || FDistortionEdge.IsChanged || FDistortionEQCenterFrequenz.IsChanged || FDistortionLowpassCutoff.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableDistortion[i])
                            {
                                Fx.EnableDistortionSoundEffect(FDistortionGain[i], FDistortionEdge[i], FDistortionEQCenterFrequenz[i], FDistortionBandwidth[i], FDistortionLowpassCutoff[i]);
                            }
                            else
                            {
                                Fx.DisableDistortionSoundEffect();
                            }
                        }
                    }
                }

                #endregion Distortion

                //Sets the Echo Effekt of a ISound Object
                #region Echo

                if (Reload || FEnableEcho.IsChanged || FEchoFeedback.IsChanged || FEchoLeftDelay.IsChanged || FEchoPanDelay.IsChanged || FEchoRightDelay.IsChanged || FEchoWetDryMix.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableEcho[i])
                            {
                                Fx.EnableEchoSoundEffect(FEchoWetDryMix[i], FEchoFeedback[i], FEchoLeftDelay[i], FEchoRightDelay[i], FEchoPanDelay[i]);
                            }
                            else
                            {
                                Fx.DisableEchoSoundEffect();
                            }
                        }
                    }
                }

                #endregion Echo

                //Sets the Flanger Effekt of a ISound Object
                #region Flanger

                if (Reload || FEnableFlanger.IsChanged || FFlangerDelay.IsChanged || FFlangerDepth.IsChanged || FFlangerFeedback.IsChanged || FFlangerFrequency.IsChanged || FFlangerPhase.IsChanged || FFlangerTriangleWaveForm.IsChanged || FFlangerWetDryMix.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableFlanger[i])
                            {
                                Fx.EnableFlangerSoundEffect(FFlangerWetDryMix[i], FFlangerDepth[i], FFlangerFeedback[i], FFlangerFrequency[i], FFlangerTriangleWaveForm[i], FFlangerDelay[i], FFlangerPhase[i]);
                            }
                            else
                            {
                                Fx.DisableFlangerSoundEffect();
                            }
                        }
                    }
                }

                #endregion Flanger

                //Sets the Gargle Effekt of a ISound Object
                #region Gargle

                if (Reload || FEnableGargle.IsChanged || FGargleRateHz.IsChanged || FGargleSinusWaveForm.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;
                            if (FEnableGargle[i])
                            {
                                Fx.EnableGargleSoundEffect(FGargleRateHz[i], FGargleSinusWaveForm[i]);
                            }
                            else
                            {
                                Fx.DisableGargleSoundEffect();
                            }
                        }
                    }
                }

                #endregion Gargle

                //Sets the I3Dl2 Reverb Effekt of a ISound Object
                #region I3Dl2 Reverb

                if (Reload || FEnableI3DL2.IsChanged || FI3DL2DecayHFRatio.IsChanged || FI3DL2DecayTime.IsChanged || FI3DL2Density.IsChanged || FI3DL2Diffusion.IsChanged || FI3DL2HfReference.IsChanged || FI3DL2ReflectionDelay.IsChanged || FI3DL2Reflections.IsChanged || FI3DL2Reverb.IsChanged || FI3DL2ReverbDelay.IsChanged || FI3DL2Room.IsChanged || FI3DL2RoomHF.IsChanged || FI3DL2RoomRollOffFactor.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableI3DL2[i])
                            {
                                Fx.EnableI3DL2ReverbSoundEffect(FI3DL2Room[i], FI3DL2RoomHF[i], FI3DL2RoomRollOffFactor[i], FI3DL2DecayTime[i], FI3DL2DecayHFRatio[i], FI3DL2Reflections[i], FI3DL2ReflectionDelay[i], FI3DL2Reverb[i], FI3DL2ReverbDelay[i], FI3DL2Diffusion[i], FI3DL2Density[i], FI3DL2HfReference[i]);
                            }
                            else
                            {
                                Fx.DisableI3DL2ReverbSoundEffect();
                            }
                        }
                    }
                }

                #endregion I3Dl2 Reverb

                //Sets the Param EQ Effekt of a ISound Objec
                #region Param EQ

                if (Reload || FEnableEq.IsChanged || FEqBandwidth.IsChanged || FEqCenter.IsChanged || FEqGain.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableEq[i])
                            {
                                Fx.EnableParamEqSoundEffect(FEqCenter[i], FEqBandwidth[i], FEqGain[i]);
                            }
                            else
                            {
                                Fx.DisableParamEqSoundEffect();
                            }
                        }
                    }
                }

                #endregion param EQ

                //Sets the Wave Effekt of a ISound Object
                #region Wave Reverb

                if (Reload || FEnableWaveReverb.IsChanged || FWaveReverbFreq.IsChanged || FWaveReverbInGain.IsChanged || FWaveReverbMix.IsChanged || FWaveReverbTime.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;

                            if (FEnableWaveReverb[i])
                            {
                                Fx.EnableWavesReverbSoundEffect(FWaveReverbInGain[i], FWaveReverbMix[i], FWaveReverbTime[i], FWaveReverbFreq[i]);
                            }
                            else
                            {
                                Fx.DisableWavesReverbSoundEffect();
                            }
                        }
                    }
                }

                #endregion Wave Reverb

                //Disables all Effekts
                #region Disable All Effekts

                if (FDisableAllEffekt.IsChanged)
                {
                    for (int i = 0; i < SpreadMax; i++)
                    {
                        if (FPlayedSounds[i] != null)
                        {
                            ISoundEffectControl Fx = FPlayedSounds[i].SoundEffectControl;
                            if (FDisableAllEffekt[i])
                            {
                                Fx.DisableAllEffects();
                            }
                        }
                    }
                }

                #endregion Disabel All Effects
            }

            #endregion Effekts


            //Reads the Output values form the ISound Object
            #region Node Output

            FCurrentPos.SliceCount = SpreadMax;
            FFinish.SliceCount     = SpreadMax;
            FMessage.SliceCount    = SpreadMax;

            //Set the OutputPin values
            for (int i = 0; i < SpreadMax; i++)
            {
                if (FPlayedSounds[i] != null)
                {
                    if (FPlayedSounds[i].Finished)
                    {
                        FCurrentPos[i] = 0.0;
                    }
                    else
                    {
                        FCurrentPos[i] = (double)(FPlayedSounds[i].PlayPosition) / 1000.0;
                    }
                }
                else
                {
                    FCurrentPos[i] = 0;
                }
                FFinish[i] = false;
            }

            foreach (int Index in FFinishedSounds)
            {
                FFinish[Index] = true;
            }

            FFinishedSounds.Clear();

            #endregion NodeOutput

            FPreviousSpreadMax = SpreadMax;
        }
Esempio n. 3
0
        public void Play(ISoundEngine engine)
        {
            Byte[] data = new Byte[this.length * 2]; // signed 16-bit

            for (Int32 i = 0; i < this.length; i++)
            {
                Int16 sample = (Int16)values[i];
                data[i * 2] += (byte)(sample >> 8);
                data[(i * 2) + 1] += (byte)(sample & 0xFF);
                //writer.Write(sample);
            }

            engine.RemoveSoundSource(name);
            this.source = engine.AddSoundSourceFromPCMData(data, name, fmt);
            engine.Play2D(name, true);
        }