public DataFileWriter() : base()
        {
            outputFile        = null;
            filename          = null;
            online            = false;
            fileWriterCommand = FileWriterCommand.Idle;

            init();
        }
Beispiel #2
0
        public WavFileWriter(int _channels) : base()
        {
            channels          = _channels;
            outputFile        = null;
            filename          = null;
            online            = false;
            fileWriterCommand = FileWriterCommand.Idle;

            init();
        }
Beispiel #3
0
        private void BnFile_buttonStateChanged(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "WAV File|*.wav";
            sfd.Title  = "Save a WAV File";
            sfd.ShowDialog();

            // If the file name is not an empty string open it for saving.
            if (sfd.FileName != "")
            {
                filename          = sfd.FileName;
                bnFile.onText     = bnFile.offText = shortfile(filename);
                fileWriterCommand = FileWriterCommand.GoOnline;
            }
        }
        public DataFileWriter(SystemPanel _owner, BinaryReader src) : base(_owner, src)
        {
            filename = src.ReadString();
            if ((filename == null) || (filename.Length < 1) || filename.Equals("[NONE]"))
            {
                filename = null;
            }
            outputFile        = null;
            online            = false;
            fileWriterCommand = FileWriterCommand.Idle;

            init();

            if (filename != null)
            {
                fileWriterCommand = FileWriterCommand.GoOnline;
            }
        }
Beispiel #5
0
        public override void tick()
        {
            if (fileWriterCommand == FileWriterCommand.GoOnline)
            {
                if (online)
                {
                    stopFile();
                }
                if (!online)
                {
                    startFile();
                }
                fileWriterCommand = FileWriterCommand.Idle;
            }
            if (fileWriterCommand == FileWriterCommand.GoOffline)
            {
                if (online)
                {
                    stopFile();
                }
                fileWriterCommand = FileWriterCommand.Idle;
            }
            if (online)
            {
                if ((writeBuf == null) || (writeBuf.Length != channels * owner.blockSize))
                {
                    writeBuf = new Int16[channels * owner.blockSize];
                }
                if ((active == null) || (active.Length != owner.blockSize))
                {
                    active = new Boolean[owner.blockSize];
                }
                Array.Clear(writeBuf, 0, writeBuf.Length);
                int smps = 0;

                SignalBuffer[] dbin = new SignalBuffer[channels];
                if ((channels > 0) && (io1.connectedTo != null))
                {
                    dbin[0] = io1.connectedTo.signalOutput;
                }
                if ((channels > 1) && (io2.connectedTo != null))
                {
                    dbin[1] = io2.connectedTo.signalOutput;
                }
                if ((channels > 2) && (io3.connectedTo != null))
                {
                    dbin[2] = io3.connectedTo.signalOutput;
                }
                if ((channels > 3) && (io4.connectedTo != null))
                {
                    dbin[3] = io4.connectedTo.signalOutput;
                }
                if ((channels > 4) && (io5.connectedTo != null))
                {
                    dbin[4] = io5.connectedTo.signalOutput;
                }
                if ((channels > 5) && (io6.connectedTo != null))
                {
                    dbin[5] = io6.connectedTo.signalOutput;
                }
                if ((channels > 6) && (io7.connectedTo != null))
                {
                    dbin[6] = io7.connectedTo.signalOutput;
                }
                if ((channels > 7) && (io8.connectedTo != null))
                {
                    dbin[7] = io8.connectedTo.signalOutput;
                }

                if (ioGate.connectedTo != null)
                {
                    SignalBuffer db = ioGate.connectedTo.signalOutput;
                    for (int i = 0; i < owner.blockSize; i++)
                    {
                        active[i] = (db.data[i] > 0.5) && manualActive;
                        if (active[i])
                        {
                            smps++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < owner.blockSize; i++)
                    {
                        active[i] = manualActive;
                    }
                    if (manualActive)
                    {
                        smps = owner.blockSize;
                    }
                }
                for (int i = 0; i < channels; i++)
                {
                    if (dbin[i] != null)
                    {
                        int idx = i;
                        for (int j = 0; j < owner.blockSize; j++, idx += channels)
                        {
                            writeBuf[idx] = doubleToInt16(dbin[i].data[j]);
                        }
                    }
                }
                try
                {
                    for (int i = 0; i < smps * channels; i++)
                    {
                        outputFile.Write(writeBuf[i]);
                    }
                } catch (Exception e) { }
                isActive = active[owner.blockSize - 1];
                samples += smps;
            }
            else
            {
                isActive = false;
            }

            if (isActive && !ledRecord.LEDState)
            {
                ledRecord.LEDState = true;
            }
            if (!isActive && ledRecord.LEDState)
            {
                ledRecord.LEDState = false;
            }
        }
Beispiel #6
0
 private void BnClose_buttonStateChanged(object sender, EventArgs e)
 {
     fileWriterCommand = FileWriterCommand.GoOffline;
     filename          = null;
     bnFile.onText     = bnFile.offText = "[NONE]";
 }
        public override void tick()
        {
            if (fileWriterCommand == FileWriterCommand.GoOnline)
            {
                if (online)
                {
                    stopFile();
                }
                if (!online)
                {
                    startFile(owner.timeStampOffset);
                }
                fileWriterCommand = FileWriterCommand.Idle;
            }
            if (fileWriterCommand == FileWriterCommand.GoOffline)
            {
                if (online)
                {
                    stopFile();
                }
                fileWriterCommand = FileWriterCommand.Idle;
            }
            if (online)
            {
                DataBuffer db = getDataInputBuffer(ioData);
                if ((db != null) && (db.size > 0))
                {
                    if (manualActive)
                    {
                        isActive = true;
                        outputFile.Write(string.Format("<dset><blk>{0}</blk><tofs>{1}</tofs>",
                                                       owner.timeStamp, (double)owner.timeStamp * owner.blockSize / owner.sampleRate));
                        outputFile.Write(string.Format("<data>{0}", db.get(0)));
                        for (int i = 1; i < db.size; i++)
                        {
                            outputFile.Write(string.Format(",{0}", db.get(i)));
                        }
                        outputFile.WriteLine("</data></dset>");
                    }
                    else
                    {
                        isActive = false;
                    }
                }
                if (db == null)
                {
                    isActive = false;
                }
            }
            else
            {
                isActive = false;
            }

            if (isActive && !ledRecord.LEDState)
            {
                ledRecord.LEDState = true;
            }
            if (!isActive && ledRecord.LEDState)
            {
                ledRecord.LEDState = false;
            }
        }