コード例 #1
0
        public static List <Tuple <double, double>[]> Test7()
        {
            int MelodySize = 44100 * 3;
            int Start      = 44100 * (60 * 4 + 15);//44100 * 30;//

            var ret = new List <Tuple <double, double>[]>();

            var musik = WavFile.Read(@"D:\Test5.wav");

            var musik1 = WavFile.Read(@"D:\Test5.wav");


            var melodyl = new int[MelodySize];
            var melodyr = new int[MelodySize];

            for (int i = 0; i < (MelodySize - 1) * 2; i += 2)//musik.DataList.Count;i++)
            {
                melodyl[i / 2]     = musik.DataList[i + Start];
                melodyr[i / 2 + 1] = musik.DataList[i + Start];
            }

            var dat = new SongData()
            {
                Left  = melodyl,
                Right = melodyr,
                leng  = MelodySize
            };

            var param = BeatPerMinutDetecter.Detector(dat);

            var Mod = new MelodyModell
            {
                BPMd = (int)param.TempD
            };


            Mod.StartSd = (Start + (int)param.StartBeat) % Mod.BPMd;

            MusicMod(ret, musik, musik1, Mod);

            WavFile.Write(@"D:\TestWP3.wav", musik);
            return(ret);
        }
コード例 #2
0
        private static void MusicMod(List <Tuple <double, double>[]> ret, WavFile musik, WavFile musik1, MelodyModell Mod)
        {
            for (int i = 0; i < musik.DataList.Count; i++)
            {
                musik.DataList[i] = (Int16)((musik.DataList[i] * 3) / 7);
            }

            var datM = musik1.DataList.Select(v => { return((double)v); }).ToArray();

            for (int i = 1; 2 * (i * Mod.BPMd) < musik.DataList.Count - Mod.BPMd; i++)
            {
                var sp = FastFourierTransform.FFTSpectr(datM, 2 * (i * Mod.BPMd), 2, 14, Mod.BPMd);

                int maxCh = 1;

                maxCh = (int)NoteDetector.DetectNote(Mod.BPMd, datM, i, Mod.BPMd);



                ret.Add(sp);

                var Bit = Generators.MusicImmitation(1 << 14, /*(int)((1 << 14) / (220 / 2.69 * ((i % 3 + 2) * 0.1)))*/ Math.Max(maxCh, 1), 5000, 10);

                for (int j = 0; j < Bit.Length && musik.DataList.Count > (i * Mod.BPMd + j + Mod.StartSd) * 2; j++)
                {
                    musik.DataList[2 * (i * Mod.BPMd + j)]     = (Int16)((Bit[j] * 4 / 7d + musik.DataList[2 * (i * Mod.BPMd + j) /*+ Mod.StartSd*/]));
                    musik.DataList[2 * (i * Mod.BPMd + j) + 1] = (Int16)((Bit[j] * 4 / 7d + musik.DataList[2 * (i * Mod.BPMd + j) + 1 /*+ Mod.StartSd*/]));
                }
            }
        }