当前位置: 首页>>代码示例>>C#>>正文


C# Scene.Attenuation方法代码示例

本文整理汇总了C#中Scene.Attenuation方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.Attenuation方法的具体用法?C# Scene.Attenuation怎么用?C# Scene.Attenuation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scene的用法示例。


在下文中一共展示了Scene.Attenuation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Receiver_Bank

            /// <summary>
            /// Receiver bank constructor.
            /// </summary>
            /// <param name="Pt">array of receiver origin points</param>
            /// <param name="SrcPT">sound source point</param>
            /// <param name="Room">the acoustical scene</param>
            /// <param name="RCT">the number or rays emanating from the source</param>
            /// <param name="CSound">the speed of sound in m/s</param>
            /// <param name="SampleRate_in">the simulation histogram sampling frequency</param>
            /// <param name="COTime_in">the Cut Off Time in ms.</param>
            /// <param name="Type">the type of receivers contained in this receiver bank</param>
            public Receiver_Bank(IEnumerable<Point3d> Pt, Point3d SrcPT, Scene Sc, int SampleRate_in, double COTime_in, double delayinms, Type Type)
            {
                delay_ms = delayinms;
                SampleRate = SampleRate_in;
                SampleCT = (int)Math.Floor(COTime_in * SampleRate_in / 1000);
                this.CutOffTime = COTime_in;
                Rec_Type = Type;
                Point3d[] arrPts = Pt.ToArray<Point3d>();
                Rec_List = new Spherical_Receiver[arrPts.Length];
                Min = new Hare.Geometry.Point(double.PositiveInfinity, double.PositiveInfinity, double.PositiveInfinity);
                Max = new Hare.Geometry.Point(double.NegativeInfinity, double.NegativeInfinity, double.NegativeInfinity);

                for (int i = 0; i < arrPts.Length; i++)
                {
                    if (Type == Type.Stationary) Rec_List[i] = new Spherical_Receiver(new Point3d(arrPts[i]), new Point3d(SrcPT), Sc.Attenuation(Utilities.PachTools.RPttoHPt(arrPts[i])), Sc.Sound_speed(Utilities.PachTools.RPttoHPt(arrPts[i])), Sc.Rho(Utilities.PachTools.RPttoHPt(arrPts[i])), SampleRate_in, COTime_in);
                    if (Type == Type.Variable) Rec_List[i] = new Expanding_Receiver(new Point3d(arrPts[i]), new Point3d(SrcPT), RayCount, Sc.Attenuation(Utilities.PachTools.RPttoHPt(arrPts[i])), Sc.Sound_speed(Utilities.PachTools.RPttoHPt(arrPts[i])), Sc.Rho(Utilities.PachTools.RPttoHPt(arrPts[i])), SampleRate_in, COTime_in);

                    if (arrPts[i].X > Max.x) Max.x = arrPts[i].X;
                    if (arrPts[i].Y > Max.y) Max.y = arrPts[i].Y;
                    if (arrPts[i].Z > Max.z) Max.z = arrPts[i].Z;
                    if (arrPts[i].X < Min.x) Min.x = arrPts[i].X;
                    if (arrPts[i].Y < Min.y) Min.y = arrPts[i].Y;
                    if (arrPts[i].Z < Min.z) Min.z = arrPts[i].Z;
                }
            }
开发者ID:philrob22,项目名称:PachydermAcoustic_Rhinoceros,代码行数:36,代码来源:Classes_Receivers.cs

示例2: Specular_Path

        public Specular_Path(Hare.Geometry.Point[] Path, int[] Seq_planes, int[] Seq_Polys, Scene Room, Source Src, double C_Sound, double[] Trans_Mod, ref double Direct_Time, int thread, int Rnd)
        {
            PathEnergy = new double[8];
            ValidPath = Path;
            //Build an Identifier
            Sequence = Seq_planes;

            Hare.Geometry.Point Pt;

            for (int q = 1; q < ValidPath.Length; q++)
            {
                Pt = ValidPath[q] - ValidPath[q - 1];
                Length += Math.Sqrt(Pt.x * Pt.x + Pt.y * Pt.y + Pt.z * Pt.z);
            }
            
            Time = Length / C_Sound + Src.Delay;
            Vector DIR = ValidPath[1] - ValidPath[0];
            DIR.Normalize();

            Random rnd = new Random(Rnd);
            float time = (float)(Length / C_Sound);
            double[] phase = Src.Phase(DIR, ref rnd);

            ///Energy based formulation
            double[] Power = Src.DirPower(thread, Rnd, DIR);
            Identify(Src.Source_ID(), Direct_Time);
            
            for (int oct = 0; oct < 8; oct++)
            {
                PathEnergy[oct] = (Power[oct] * Math.Pow(10,-.1 * Room.Attenuation(0)[oct] * Length) / (4 * Math.PI * Length * Length));
                PathEnergy[oct] *= Trans_Mod[oct];
            }

            foreach (int q in Seq_Polys)
            {
                if (!(Room.AbsorptionValue[q] is Basic_Material)) continue;
                double[] AbsorptionData = Room.AbsorptionValue[q].Coefficient_A_Broad();
                double[] ScatteringData = Room.ScatteringValue[q].Coefficient();
                for (int t = 0; t <= 7; t++)
                {
                    PathEnergy[t] *= (1 - AbsorptionData[t]) * (1 - ScatteringData[t]);
                }
            }

            prms = new double[8];

            for (int i = 0; i < 8; i++) prms[i] = Math.Sqrt(PathEnergy[i] * Room.Rho_C(Path[0]));

            //System.Numerics.Complex[] Pspec = Audio.Pach_SP.Mirror_Spectrum(Audio.Pach_SP.Magnitude_Spectrum(prms, 44100, 4096, thread));
            //System.Numerics.Complex[] Pspec = Audio.Pach_SP.Mirror_Spectrum(Audio.Pach_SP.Magnitude_Spectrum(prms, 88200, 4096, thread));

            Special_Filter = new System.Numerics.Complex[4096];
            for (int i = 0; i < Special_Filter.Length; i++) Special_Filter[i] = 1;

            foreach (int q in Seq_Polys)
            {
                if (Room.AbsorptionValue[q] is Basic_Material) continue; 
                //Pressure based formulation of materials
                for (int i = 0; i < Seq_Polys.Length; i++)
                {
                    Hare.Geometry.Vector d = Path[i + 1] - Path[i + 2]; d.Normalize();
                    if (!(Room.AbsorptionValue[Seq_Polys[i]] is Basic_Material))
                    {
                        System.Numerics.Complex[] Ref = Room.AbsorptionValue[Seq_Polys[i]].Reflection_Spectrum(44100, 4096, Room.Normal(Seq_Polys[i]), d, thread);
                        //System.Numerics.Complex[] Ref = Room.AbsorptionValue[Seq_Polys[i]].Reflection_Spectrum(88200, 4096, Room.Normal(Seq_Polys[i]), d, thread);
                        //for (int j = 0; j < Pspec.Length; j++) Pspec[j] *= Ref[j];
                        for (int j = 0; j < Special_Filter.Length; j++) Special_Filter[j] *= Ref[j];
                    }
                }
            }

            Create_pressure(44100, 4096, thread);

            //double[] tank = new double[Pspec.Length];
            //for (int i = 0; i < tank.Length; i++) tank[i] = Pspec[i].Real;
            //P = Audio.Pach_SP.Minimum_Phase_Response(tank, 44100, thread);
            //TODO: Investigate phase propoerties of this for special materials filters...
            //double[] pre = Audio.Pach_SP.IFFT_Real4096(Pspec, thread);
            //P = new double[pre.Length];
            //double scale = Math.Sqrt(P.Length);
            //int hw = P.Length / 2;
            //for (int i = 0; i < pre.Length; i++) P[i] = pre[(i + hw) % pre.Length] / scale;
            /////////////////////////////////
            //Audio.Pach_SP.resample(ref P);
            ///////////////////////////////
            //Audio.Pach_SP.Raised_Cosine_Window(ref P);
        }
开发者ID:hezihertz,项目名称:PachyDerm_Mod,代码行数:87,代码来源:Classes_ImageSource.cs

示例3: Spherical_Receiver

 /// <summary>
 /// Constructor which takes Hare Point input.
 /// </summary>
 /// <param name="Center"></param>
 /// <param name="SrcCenter"></param>
 /// <param name="room"></param>
 /// <param name="RCT"></param>
 /// <param name="C_Sound_in"></param>
 /// <param name="SampleRate_in"></param>
 /// <param name="COTime_in"></param>
 public Spherical_Receiver(Hare.Geometry.Point Center, Hare.Geometry.Point SrcCenter, Scene room, double C_Sound_in, int SampleRate_in, double COTime_in)
 {
     D_Length = Math.Sqrt(Center.x * SrcCenter.x + Center.y * SrcCenter.y * Center.z * SrcCenter.z);
     Radius = 1;
     Radius2 = Radius * Radius;
     CO_Time = COTime_in;
     SampleRate = SampleRate_in;
     H_Origin = Center;
     //Origin = new Point3d(Center.x, Center.y, Center.z);
     Sound_Speed = C_Sound_in;
     Atten = room.Attenuation(Center);
     SizeMod = 1 / Math.PI;
     Recs = new Directional_Histogram(SampleRate, CO_Time);
 }
开发者ID:philrob22,项目名称:PachydermAcoustic_Rhinoceros,代码行数:24,代码来源:Classes_Receivers.cs


注:本文中的Scene.Attenuation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。