Пример #1
0
 public Note(NoteType type, PitchName pitch, int octave, bool isDotted, Accidentals accidental, bool isOverlaid)
 {
     Pitch      = pitch;
     Accidental = accidental;
     Octave     = octave;
     Type       = type;
     IsDotted   = isDotted;
     IsOverlaid = isOverlaid;
 }
Пример #2
0
    // Init called from the GuitarString object that holds the notes
    public void Init(int _noteID, int _octave, int _fret)
    {
        notePitch         = noteInfo.PitchNames [_noteID];
        sharp             = noteInfo.Sharps [_noteID];
        noteIdentifer     = noteInfo.Identifiers [_noteID];
        noteText.richText = true;
        noteRichText      = "<b>" + noteInfo.NoteRichTexts [_noteID] + "</b>";
        if (noteInfo.Sharps [_noteID] == true)
        {
            noteRichText += "<size=38>#</size>";
        }

        noteColor      = (_noteID / 12.0f) - 0.1f;
        noteText.text  = noteRichText;
        noteText.color = Color.HSVToRGB(noteColor, 1.0f, 1.0f);
        isColored      = true;

        fret            = _fret;
        octave          = _octave;
        noteSource      = gameObject.GetComponent <AudioSource>();
        clip            = clips.audioClips [octave];
        noteSource.clip = clip;
    }
        public void BuildKeySound()
        {
            Task.Run(() =>
            {
                isWorking = true;
                NotifyOfPropertyChange(() => CanListenDemo);
                NotifyOfPropertyChange(() => CanBuildKeySound);
                NotifyOfPropertyChange(() => CanOpenSoundfont2);

                if (NeedParseDir && !string.IsNullOrEmpty(ParseDir))
                {
                    DirectoryInfo parseDirInfo = new DirectoryInfo(ParseDir);
                    if (!parseDirInfo.Exists)
                    {
                        MessageBox.Show("Can't find parse dir");
                        goto clean;
                    }
                    foreach (var files in parseDirInfo.GetFiles())
                    {
                        if (files.Extension == ".wav" ||
                            files.Extension == ".ogg" ||
                            files.Extension == ".mp3")
                        {
                            string ksFile           = files.Name;
                            string ksFileWithoutExt = ksFile.Substring(0, ksFile.LastIndexOf('.'));
                            string[] ksArg          = ksFileWithoutExt.Split('_');
                            int instrVal            = int.Parse(ksArg[0]);
                            int pitchIdxVal         = 0;
                            int OctaveIdxVal        = 0;
                            if (ksArg[1].Contains("#"))
                            {
                                pitchIdxVal  = PitchName.IndexOf(ksArg[1].Substring(0, 2));
                                OctaveIdxVal = int.Parse(ksArg[1].Substring(2, ksArg[1].Length - 2));
                            }
                            else
                            {
                                pitchIdxVal  = PitchName.IndexOf(ksArg[1].Substring(0, 1));
                                OctaveIdxVal = int.Parse(ksArg[1].Substring(1, ksArg[1].Length - 1));
                            }
                            int keyVal       = pitchIdxVal + (OctaveIdxVal + 2) * 12;
                            int bpmVal       = int.Parse(ksArg[2]);
                            double lengthVal = double.Parse(ksArg[3]) / 480;

                            string tmpDir = Path.GetTempPath();
                            if (BuildTypeMid)
                            {
                                string midiFilename = $"{OutputDir}\\{ksFileWithoutExt}.mid";
                                maker.GenKeySoundMidi(midiFilename, instrVal, keyVal, bpmVal, lengthVal, 115, false);
                                OutputFilename = midiFilename;
                            }
                            else
                            {
                                string midiFilename = $"{tmpDir}\\{ksFileWithoutExt}.mid";
                                maker.GenKeySoundMidi(midiFilename, instrVal, keyVal, bpmVal, lengthVal, 115, false);
                                if (BuildTypeWav)
                                {
                                    string wavFilename = $"{OutputDir}\\{ksFileWithoutExt}.wav";
                                    maker.SetOutputFilename(wavFilename);
                                    maker.RenderMiditoWav(midiFilename);
                                    OutputFilename = wavFilename;
                                }
                                else
                                {
                                    string wavFilename = $"{tmpDir}\\{ksFileWithoutExt}.wav";
                                    maker.SetOutputFilename(wavFilename);
                                    maker.RenderMiditoWav(midiFilename);
                                    string mp3Filename = $"{OutputDir}\\{ksFileWithoutExt}.mp3";
                                    maker.EncodeWavtoMp3(wavFilename, mp3Filename);
                                    OutputFilename = mp3Filename;
                                }
                            }
                        }
                    }
                    goto clean;
                }

                int instrument;
                int key;
                if (!IsDrum)
                {
                    key        = PitchIdx + (OctaveIdx + 1) * 12;
                    instrument = InstTypeIdx * 8 + InstNameIdx;
                }
                else
                {
                    instrument = 0;
                    key        = 35 + InstNameIdx;
                }
                if (key > 127)
                {
                    MessageBox.Show("No such key");
                }
                else
                {
                    int tick        = (int)(480 * Length);
                    string filename = MusicTheory.GetFileName(instrument, key, (int)Bpm, (int)tick, Volume, IsDrum);
                    string tmpDir   = System.IO.Path.GetTempPath();
                    if (BuildTypeMid)
                    {
                        string midiFilename = $"{OutputDir}\\{filename}.mid";
                        maker.GenKeySoundMidi(midiFilename, instrument, key, Bpm, Length, Volume, IsDrum);
                        OutputFilename = midiFilename;
                    }
                    else
                    {
                        string midiFilename = $"{tmpDir}\\{filename}.mid";
                        maker.GenKeySoundMidi(midiFilename, instrument, key, Bpm, Length, Volume, IsDrum);
                        if (BuildTypeWav)
                        {
                            string wavFilename = $"{OutputDir}\\{filename}.wav";
                            maker.SetOutputFilename(wavFilename);
                            maker.RenderMiditoWav(midiFilename);
                            OutputFilename = wavFilename;
                        }
                        else
                        {
                            string wavFilename = $"{tmpDir}\\{filename}.wav";
                            maker.SetOutputFilename(wavFilename);
                            maker.RenderMiditoWav(midiFilename);
                            string mp3Filename = $"{OutputDir}\\{filename}.mp3";
                            maker.EncodeWavtoMp3(wavFilename, mp3Filename);
                            OutputFilename = mp3Filename;
                        }
                    }
                }

                clean: isWorking = false;
                NotifyOfPropertyChange(() => CanListenDemo);
                NotifyOfPropertyChange(() => CanBuildKeySound);
                NotifyOfPropertyChange(() => CanOpenSoundfont2);
            });
        }
Пример #4
0
 public Chord(PitchName root, List <Degree> type)
 {
     this.root = root;
     this.type = type;
 }
Пример #5
0
 public MajorScale(PitchName key)
 {
     this.key = key;
 }