Esempio n. 1
0
        /// <summary>
        /// The newSampleMenuItem_Click event handler creates a new SampleControlCollection and adds a new sample to the
        /// PatternSampleProvider set to a default file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newSampleMenuItem_Click(object sender, EventArgs e, int button)
        {
            string defaultFile = "D:\\VS Workspace\\NAudioSampleSequencerForms\\NAudioSampleSequencerForms\\Samples\\snare-trimmed.wav";

            SampleControlCollection scc = new SampleControlCollection();

            sccList.Add(scc);
            scc.Name     = "scc" + (sccList.Count - 1);
            scc.Location = new Point(0, 0 + (100 * (sccList.Count - 1)));
            scc.AddToComboBox(defaultFile);

            sccPanels[button].Controls.Add(scc);

            patternSequencer.Samples.AddNewSample(defaultFile);

            AddNewSampleRow();
        }
Esempio n. 2
0
        //private MixingSampleProvider mixer;

        public Form1()
        {
            InitializeComponent();

            tempo     = Convert.ToInt32(tempoTextBox.Text);
            sccList   = new List <SampleControlCollection>();
            notes     = new List <string>();
            sccPanels = new List <Panel>();

            //patternDataGrid initialization
            patternDataGrid.ColumnCount = 17;
            patternDataGrid.RowCount    = 4;

            patternDataGrid.CellClick += new DataGridViewCellEventHandler(patternDataGrid_CellClick);

            //add the sample names to List for use on the patternDataGrid
            notes.Add("kick-trimmed.wav");
            notes.Add("snare-trimmed.wav");
            notes.Add("closed-hats-trimmed.wav");
            notes.Add("open-hats-trimmed.wav");

            //initialize the Pattern
            this.pattern = new Pattern(notes, 16);

            // auto-setup with a simple example beat
            this.pattern[0, 0] = this.pattern[0, 8] = 127;
            this.pattern[1, 4] = this.pattern[1, 12] = 127;
            for (int n = 0; n < pattern.Steps; n++)
            {
                this.pattern[2, n] = 127;
            }

            //"draw" the sample names and the pattern onto the patternDataGrid
            DrawNoteNames();
            DrawPattern();

            patternSequencer = new PatternSampleProvider(pattern);

            //SampleControlCollection initialization
            string[] defaultFiles = { patternSequencer.Samples.FilePaths[0],
                                      patternSequencer.Samples.FilePaths[1],
                                      patternSequencer.Samples.FilePaths[2],
                                      patternSequencer.Samples.FilePaths[3] };

            //create panel to group together the initial SampleControlCollections for pattern 1
            Panel panel = new Panel();

            panel.Location = new Point(0, 350);
            panel.AutoSize = true;

            for (int i = 0; i < 4; i++)
            {
                SampleControlCollection scc = new SampleControlCollection();
                sccList.Add(scc);
                scc.Name     = "scc" + (sccList.Count - 1);
                scc.Location = new Point(0, 0 + (100 * (sccList.Count - 1)));
                scc.AddToComboBox(defaultFiles[i]);

                panel.Controls.Add(scc);
            }

            sccPanels.Add(panel);
            this.Controls.Add(panel);

            //add button to newSampleMenuItem to add new samples to Pattern 1
            //ToolStripDropDown newButton = new ToolStripDropDown();
            //newButton.Name = "newSamplePattern" + (newSampleMenuItem.DropDownItems.Count + 1);
            //newButton.Text = "Pattern " + (newSampleMenuItem.DropDownItems.Count + 1);
            //newButton.Click += (sender, e) => newSampleMenuItem_Click(sender, e, (newSampleMenuItem.DropDownItems.Count + 1));
            newSampleMenuItem.DropDownItems.Add("Pattern " + (newSampleMenuItem.DropDownItems.Count + 1));
            newSampleMenuItem.DropDownItems[0].Name   = "newSamplePattern" + (newSampleMenuItem.DropDownItems.Count + 1);
            newSampleMenuItem.DropDownItems[0].Click += (sender, e) => newSampleMenuItem_Click(sender, e, 0);

            //mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(16000, 2));
        }