Ejemplo n.º 1
0
        //turn hue to sound
        private void backgroundWorker1_DoWork_1(object sender, DoWorkEventArgs e)
        {
            var      backgroundWorker = sender as BackgroundWorker;
            MIDIFile m = new MIDIFile();

            int[,] note = toNormalizedHue(imagePath);
            m.setVolume(127);
            int noOfSteps          = note.GetLength(0) * note.GetLength(1);
            int reportProgressStep = noOfSteps / 100 + 1;
            int step = 0;

            for (int i = 0; i < note.GetLength(0); i++)
            {
                for (int j = 0; j < note.GetLength(1); j++)
                {
                    m.addNote(note[i, j]); //create MIDI file of notes acquired from the hue channel of the image
                    step++;
                    if (step % reportProgressStep == 0)
                    {
                        backgroundWorker.ReportProgress(step / reportProgressStep);
                    }
                }
            }
            m.createMIDIFile("test"); //create MIDI file
            backgroundWorker.ReportProgress(100);
            musicFilePath = Directory.GetCurrentDirectory() + "\\test.mid";
        }
Ejemplo n.º 2
0
        //turn hue to sound
        static void imageToSound(string path) //path to image
        {
            MIDIFile m = new MIDIFile();


            int[,] note = toNormalizedHue(path);

            m.setVolume(127);
            for (int i = 0; i < note.GetLength(0); i++)
            {
                for (int j = 0; j < note.GetLength(1); j++)
                {
                    m.addNote(note[i, j]); //create MIDI file of notes acquired from the hue channel of the image
                }
            }
            m.createMIDIFile("test"); //create MIDI file
        }