Exemple #1
0
        //public short[] getBuffer(int sampleToRead)
        //{
        //    numOfBytes = dsInterface.aSound[sampleToRead].Caps.BufferBytes;
        //    int bytesPerSample = dsInterface.aSound[sampleToRead].Format.BitsPerSample / 8;

        //    CreateStreamBuffers();
        //    CreateStreams();

        //    // Create a 16bit Buffer for the total number of samples assuming the maximum
        //    // bits per sample is 16
        //    int iNumOfSamples = numOfBytes / bytesPerSample;
        //    short[] Points = new Int16[iNumOfSamples];

        //    // Read the complete stream in to a memory stream
        //    dsInterface.aSound[sampleToRead].Read(0, stream0, numOfBytes, Microsoft.DirectX.DirectSound.LockFlag.EntireBuffer);


        //    //System.Windows.Forms.MessageBox.Show(bytesPerSample.ToString());


        //    // Get the data from the sample
        //    for(int i=0; i < numOfBytes; i = i + bytesPerSample)
        //    {
        //        Int16 iSample = 0;

        //        switch (bytesPerSample)
        //        {
        //            case 1:
        //                //Int16Converter iC = new Int16Converter();
        //                //iC.ConvertFrom(
        //                iSample = streamBuffer0[i];
        //                Points[i] = iSample;
        //                break;
        //            case 2:
        //                iSample = streamBuffer0[i + 1];
        //                // Shifts the data 8 bits to the left
        //                iSample <<= 8;
        //                // Performs a Bitwise logical OR
        //                iSample |= streamBuffer0[i];
        //                Points[i / 2] = iSample;
        //                break;
        //            default:
        //                break;
        //        }

        //    }
        //    return Points;
        //}


        //private void CreateStreamBuffers()
        //{
        //    streamBuffer0 = new byte[numOfBytes];
        //    for (int i = 0; i < numOfBytes; i++)
        //        streamBuffer0[i] = 0;

        //    streamBuffer1 = new byte[numOfBytes];
        //    for (int i = 0; i < numOfBytes; i++)
        //        streamBuffer1[i] = 0;
        //}


        //private void CreateStreams()
        //{
        //    stream0 = new MemoryStream(streamBuffer0);
        //    stream1 = new MemoryStream(streamBuffer1);
        //}


        private void frmWavePlot_Load(object sender, EventArgs e)
        {
            //short[] buff = getBuffer(_Sample);

            // The code which uses the custom control
            //waveDisplay1.Setup(dsInterface.aSound[_Sample].Format.Channels, buff, (int)(dsInterface.aSound[_Sample].Caps.BufferBytes / (dsInterface.aSound[_Sample].Format.BitsPerSample / 8.0f)), dsInterface.aSound[_Sample].Frequency, 100f);
            //waveDisplay1.ShowWave();
            //_WaveBitmap = waveDisplay1.getWaveBitmap();

            //int TextualSample = _Sample + 1;
            //this.Text = "Sample :: " + TextualSample.ToString();

            this.Text = "Sample View :: " + globalSettings.osj.sampleDetails_sampleName[_Sample];


            // This code usese the bufferGraph class insead of the control
            bufferGraph bGraph = new bufferGraph();

            // Interface simplified, ask for a bitmap and get it (format predefined in bufferGraph class though ;-)
            _WaveBitmap = bGraph.getGraph(_Sample);


            //short[] buff = bGraph.getBuffer(_Sample);
            //bGraph.Setup(dsInterface.aSound[_Sample].Format.Channels, buff, (int)(dsInterface.aSound[_Sample].Caps.BufferBytes / (dsInterface.aSound[_Sample].Format.BitsPerSample / 8.0f)), dsInterface.aSound[_Sample].Frequency, 100f, 800, 250);
            //bGraph.ShowWave();
            //_WaveBitmap = bGraph.getWaveBitmap();
        }
Exemple #2
0
        /// <summary>
        /// Used when adding instances back to the screen, after reloading from a file or when the track editor has been
        /// closed and reopened
        /// </summary>
        /// <param name="Location"></param>
        private void addNewInstance(int Location)
        {
            // Need to do this before adding the controls, otherwise would trigger multiple screen redraws
            this.SuspendLayout();

            this._sampleInstance[_storedInstances] = new System.Windows.Forms.Label();

            this._sampleInstance[_storedInstances].Location = new System.Drawing.Point(Location, globalSettings.osj.TrackEditor_SampleStartingTopOffset);
            this._sampleInstance[_storedInstances].TabIndex = _storedInstances;
            this._sampleInstance[_storedInstances].Cursor   = System.Windows.Forms.Cursors.Default;

            this._sampleInstance[_storedInstances].BackColor   = System.Drawing.Color.White;
            this._sampleInstance[_storedInstances].ForeColor   = System.Drawing.Color.Black;
            this._sampleInstance[_storedInstances].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this._sampleInstance[_storedInstances].FlatStyle   = System.Windows.Forms.FlatStyle.Flat;

            this._sampleInstance[_storedInstances].Height = 100;
            this._sampleInstance[_storedInstances].Width  = (int)(dsInterface.getLength(_sample) * (float)(1000 / globalSettings.osj.TrackEditor_Tick));

            // TODO: Add movement controls for samples here
            this._sampleInstance[_storedInstances].MouseMove += new System.Windows.Forms.MouseEventHandler(this._sampleInstance_MouseMove);
            this._sampleInstance[_storedInstances].MouseDown += new System.Windows.Forms.MouseEventHandler(this._sampleInstance_MouseDown);

            // New instance of bufferGraph (used to add an image of the sample to the track)
            bufferGraph bGraph = new bufferGraph();

            // Interface simplified, ask for a bitmap and get it (format predefined in bufferGraph class though ;-)
            // Uses height twice the size of the label so that it is bigger and better
            this._sampleInstance[_storedInstances].Image = bGraph.getGraph(_sample, this._sampleInstance[_storedInstances].Width, 200);


            this.Controls.Add(this._sampleInstance[_storedInstances]);
            this._sampleInstance[_storedInstances].BringToFront();

            this.ResumeLayout(false);
            this.PerformLayout();
        }