public void DrawWaveFormValues(float[] samples, int offset, int length)
    {
        if (samples == null || samples.Length == 0 ||
            !dynTexture.IsInitialized)
        {
            return;
        }

        dynTexture.ClearTexture();

        // Draw the waveform
        for (int x = 0; x < dynTexture.TextureWidth; x++)
        {
            int sampleIndex = offset + length * x / dynTexture.TextureWidth;
            if (sampleIndex >= samples.Length)
            {
                break;
            }

            float value = samples[sampleIndex];

            // Draw the pixels
            int y = (int)(dynTexture.TextureHeight * (value + 1f) / 2f);
            dynTexture.SetPixel(x, y, waveformColor);
        }

        // upload to the graphics card
        dynTexture.ApplyTexture();
    }
    private void DrawHorizontalGridLine(int midiNote, Color color)
    {
        int height = settings.SongEditorSettings.GridSizeInDevicePixels;

        if (height <= 0)
        {
            return;
        }

        float yPercent = (float)noteAreaControl.GetVerticalPositionForMidiNote(midiNote);
        int   fromY    = (int)(yPercent * dynamicTexture.TextureHeight);
        int   toY      = fromY + height;

        for (int x = 0; x < dynamicTexture.TextureWidth; x++)
        {
            for (int y = fromY; y < toY && y < dynamicTexture.TextureHeight; y++)
            {
                dynamicTexture.SetPixel(x, y, color);
            }
        }
    }