示例#1
0
 public static double[] AsDoubles(Synthesizer.Fixed64[] a)
 {
     //Debug.Assert(sizeof(Synthesizer.Fixed64) == sizeof(double));
     UnsafeArrayCastLong cast = new UnsafeArrayCastLong();
     cast.fixed64s = a;
     return cast.doubles;
 }
示例#2
0
 public static long[] AsLongs(double[] a)
 {
     Debug.Assert(sizeof(long) == sizeof(double));
     UnsafeArrayCastLong cast = new UnsafeArrayCastLong();
     cast.doubles = a;
     return cast.longs;
 }
示例#3
0
 public static double[] AsDoubles(ulong[] a)
 {
     Debug.Assert(sizeof(ulong) == sizeof(double));
     UnsafeArrayCastLong cast = new UnsafeArrayCastLong();
     cast.ulongs = a;
     return cast.doubles;
 }
            /* generate one sequence of samples */
            public SynthErrorCodes Generate(
                int nActualFrames,
                float[] workspace,
                int RawBufferLOffset,
                int RawBufferROffset,
                int PrivateWorkspaceLOffset,
                int PrivateWorkspaceROffset,
                SynthParamRec SynthParams)
            {
                SynthErrorCodes error = SynthErrorCodes.eSynthDone;

                WaveTableStateRec State = this;

#if DEBUG
                Debug.Assert(!SynthParams.ScratchWorkspace1InUse);
                SynthParams.ScratchWorkspace1InUse = true;
                Debug.Assert(!SynthParams.ScratchWorkspace3InUse);
                SynthParams.ScratchWorkspace3InUse = true;
#endif
                int      loudnessWorkspaceOffset = SynthParams.ScratchWorkspace1LOffset;
                int      indexWorkspaceOffset    = SynthParams.ScratchWorkspace3Offset;
                double[] indexWorkspace          = UnsafeArrayCastLong.AsDoubles(SynthParams.ScratchWorkspace3);

                if (State.PreStartCountdown <= 0)
                {
                    if (State.OscEffectGenerator == null)
                    {
                        /* normal case */
                        if (State.WaveTableWasDefined)
                        {
                            Wave_Stereo(
                                State,
                                nActualFrames,
                                workspace,
                                RawBufferLOffset,
                                RawBufferROffset,
                                loudnessWorkspaceOffset,
                                indexWorkspace,
                                indexWorkspaceOffset);
                        }
                    }
                    else
                    {
                        /* effect postprocessing case */

                        /* initialize private storage */
                        FloatVectorZero(
                            workspace,
                            PrivateWorkspaceLOffset,
                            nActualFrames);
                        FloatVectorZero(
                            workspace,
                            PrivateWorkspaceROffset,
                            nActualFrames);

                        /* generate waveform */
                        if (State.WaveTableWasDefined)
                        {
                            Wave_Stereo(
                                State,
                                nActualFrames,
                                workspace,
                                PrivateWorkspaceLOffset,
                                PrivateWorkspaceROffset,
                                loudnessWorkspaceOffset,
                                indexWorkspace,
                                indexWorkspaceOffset);
                        }

#if DEBUG
                        SynthParams.ScratchWorkspace1InUse = false;
                        SynthParams.ScratchWorkspace3InUse = false;
#endif

                        /* apply processor to it */
                        error = ApplyOscEffectGenerator(
                            State.OscEffectGenerator,
                            workspace,
                            PrivateWorkspaceLOffset,
                            PrivateWorkspaceROffset,
                            nActualFrames,
                            SynthParams);
                        if (error != SynthErrorCodes.eSynthDone)
                        {
                            goto Error;
                        }

                        /* copy out data */
                        FloatVectorAcc(
                            workspace,
                            PrivateWorkspaceLOffset,
                            workspace,
                            RawBufferLOffset,
                            nActualFrames);
                        FloatVectorAcc(
                            workspace,
                            PrivateWorkspaceROffset,
                            workspace,
                            RawBufferROffset,
                            nActualFrames);
                    }
                }


Error:

#if DEBUG
                SynthParams.ScratchWorkspace1InUse = false;
                SynthParams.ScratchWorkspace3InUse = false;
#endif

                return(error);
            }