Exemplo n.º 1
0
        private void CreateBar(waveform form, BarType barType)
        {
            List <NoteType> notesInBar = new List <NoteType>();

            int[] pitchIndexes;
            if (currentBar == 1)
            {
                notesInBar   = barMaker.BarNotes(barType);
                pitchIndexes = pitcher.GenerateNotes(barType, rootInScale + (scale.Length / 3), previousNote, notesInBar.Count, scale.Length);
            }
            else if (currentBar == totalBars)
            {
                notesInBar   = barMaker.BarNotes(barType);
                pitchIndexes = pitcher.GenerateNotes(barType, rootInScale + (scale.Length / 3), previousNote, notesInBar.Count, scale.Length);
            }
            else
            {
                notesInBar   = barMaker.BarNotes(barType);
                pitchIndexes = pitcher.GenerateNotes(barType, rootInScale + (scale.Length / 3), previousNote, notesInBar.Count, scale.Length);
            }
            previousNote = pitchIndexes.Last <int>();
            for (int i = 0; i < notesInBar.Count; ++i)
            {
                float noteDuration = noteDurations[(int)notesInBar[i]];
                buffer.AddRange(noteOutput.NoteFromA3(scale[pitchIndexes[i]], noteDuration, form));
            }
            currentBar++;
        }
Exemplo n.º 2
0
        public void ChangeVolume(float volume)
        {
            volume *= volume * volume;

            NoteGenerator tng = new NoteGenerator();

            this.volume   = volume;
            workingBuffer = tng.NoteFromA3(13, 0.3f, waveform.sine);
            save("volume.wav");
            beep.Play();
        }
Exemplo n.º 3
0
        public List <float> makeTrack(int[] scale, int keyIndex, float tempo, int nOf4Bars, waveform form, float timeSignature, float seed)
        {
            int[] wrapped;
            wrapped = getIndexes(keyIndex, scale, scale.Length / 3);
            List <float>  buffer   = new List <float>();
            List <float>  fourBars = new List <float>();
            NoteGenerator ng       = new NoteGenerator();
            Random        r        = new Random((int)(seed * 10000.0f));

            for (int i = 0; i < 4; i++)
            {
                fourBars.AddRange(ng.NoteFromA3(wrapped[r.Next(5)], (60 / tempo) * timeSignature * 4.0f, form));
            }
            for (int i = 0; i < nOf4Bars; i++)
            {
                buffer.AddRange(fourBars);
            }
            return(buffer);
        }