Beispiel #1
0
 public static void Completion(
     AudioFilePlayGeneratorParams <T, W> generatorParams,
     ref ClipInfo clipInfo)
 {
     generatorParams.reader.Close();
     generatorParams.reader = null;
 }
Beispiel #2
0
        public static void Completion(
            PlayFileWithEffectsGeneratorParams <T, W> generatorParams,
            ref ClipInfo clipInfo)
        {
            if (generatorParams.synthState != null)
            {
                Synthesizer.SynthStateRec.FinalizeSynthesizer(
                    generatorParams.synthState,
                    (generatorParams.result == Synthesizer.SynthErrorCodes.eSynthDone) && (generatorParams.exception == null) /*writeOutputLogs*/);
                generatorParams.synthState = null;
            }

            if (generatorParams.reader != null)
            {
                generatorParams.reader.Close();
                generatorParams.reader = null;
            }
            if (generatorParams.stream != null)
            {
                generatorParams.stream.Close();
                generatorParams.stream = null;
            }

            string interactionLogFinal = generatorParams.interactionLog.ToString();

            if (interactionLogFinal.Length != 0)
            {
                IInteractionWindowService interaction = generatorParams.mainWindow.GetInteractionWindow();
                interaction.Append(interactionLogFinal);
            }

            string message = null;

            if (generatorParams.exception != null)
            {
                message = generatorParams.exception.ToString();
            }
            else if (generatorParams.result != Synthesizer.SynthErrorCodes.eSynthDone)
            {
                message = Synthesizer.GetErrorMessage(generatorParams.result, generatorParams.errorInfo);
            }
            if (message != null)
            {
                MessageBox.Show(message, "Synthesis Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
        public static void SynthesizerCompletion(
            SynthesizerGeneratorParams <T, W> generatorParams,
            ref ClipInfo clipInfo)
        {
            string interactionLogFinal = generatorParams.interactionLog.ToString();

            if (interactionLogFinal.Length != 0)
            {
                IInteractionWindowService interaction = generatorParams.mainWindow.GetInteractionWindow();
                interaction.Append(interactionLogFinal);
            }

            string message = null;

            if (generatorParams.exception != null)
            {
                message = generatorParams.exception.ToString();
            }
            else if (generatorParams.result != Synthesizer.SynthErrorCodes.eSynthDone)
            {
                message = Synthesizer.GetErrorMessage(generatorParams.result, generatorParams.errorInfo);
            }
            if (message != null)
            {
                MessageBox.Show(message, "Synthesis Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            if ((message == null) && generatorParams.clipWarn && (clipInfo.clippedSampleCount != 0))
            {
                string clippingMessage = String.Format(
                    "{0} out of {1} samples were clipped, with a maximum overextent of {2:0.000000}. Set the inverse volume to be greater than {3:0.000000} to eliminate the clipping.",
                    clipInfo.clippedSampleCount,
                    clipInfo.totalSampleCount,
                    clipInfo.maxClipExtent,
                    clipInfo.maxClipExtent * generatorParams.overallVolumeScalingReciprocal);
                MessageBox.Show(clippingMessage, "Clipping Ocurred", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #4
0
 public static void Completion(
     WaveTableTestGeneratorParams<T, W> generatorParams,
     ref ClipInfo clipInfo)
 {
 }
        public static OutputGeneric <T, U, W> Do(
            string baseName,
            GetDestinationMethod <T> getDestination,
            CreateDestinationHandlerMethod <T, W> createDestinationHandler,
            W destinationHandlerParams,
            GeneratorMainLoopMethod <T, U, W> generatorMainLoop,
            U generatorParams,
            GeneratorCompletionMethod <U> generatorCompletion,
            NumChannelsType channels,
            NumBitsType bits,
            int samplingRate,
            int oversamplingFactor,
            bool showProgressWindow,
            bool modal) // modal is only meaningful when showProgressWindow==true
        {
            // set up processing record

            OutputGeneric <T, U, W> state = new OutputGeneric <T, U, W>();

            state.channels           = channels;
            state.bits               = bits;
            state.samplingRate       = samplingRate;
            state.oversamplingFactor = oversamplingFactor;

            state.totalSampleCount          = 0;
            state.clippedSampleCount        = 0;
            state.maxClipExtent             = 0;
            state.oversamplingSkipCarryover = 0;


            if ((state.bits == NumBitsType.eSample8bit) || (state.bits == NumBitsType.eSample16bit))
            {
                if (OutputGeneric <T, U, W> .UseHPTRI) // TODO: add dither selector to global settings
                {
                    state.ditherState = new Synthesizer.StereoDither_HPTRI(bits);
                }
                else
                {
                    state.ditherState = new Synthesizer.StereoDither_TPDF(bits);
                }
            }

            if (!getDestination(out state.destination))
            {
                return(null);
            }

            state.createDestinationHandler = createDestinationHandler;

            state.generatorMainLoop   = generatorMainLoop;
            state.generatorParams     = generatorParams;
            state.generatorCompletion = generatorCompletion;

            state.destinationHandlerParams = destinationHandlerParams;

            state.stopper = new Synthesizer.StopTask();

            state.waitFinishedHelper = new WaitFinishedHelper();


            // All synth parameter initialization must be done by this point to avoid race conditions!!!
            state.thread = new Thread(ThreadMain);
            state.thread.Start(state);


            if (showProgressWindow)
            {
                state.progressWindow = new OutputProgressWindow(
                    baseName,
                    true /*show clipping*/,
                    state,
                    state,
                    state.stopper,
                    state.waitFinishedHelper,
                    state.waitFinishedHelper,
                    delegate()
                {
                    ClipInfo clipInfo = new ClipInfo(
                        state.totalSampleCount,
                        state.clippedSampleCount,
                        state.maxClipExtent);

                    state.generatorCompletion(
                        generatorParams,
                        ref clipInfo);
                });
                if (modal)
                {
                    state.progressWindow.ShowDialog();
                    state.Dispose(); // suppress finalize
                }
                else
                {
                    state.progressWindow.Show();
                    // client required to dispose after completion
                }
            }

            // After this, the dialog prevents UI interaction with the application on the main thread
            // and the rendering thread does it's thing until finished.
            // The dialog and the rendering thread talk to each other about stopping and completion.

            return(state);
        }