Example #1
0
        public bool SeparateWithSoX(string mogg, SongData song)
        {
            Tools = new NemoTools();
            try
            {
                if (Tools.MoggIsEncrypted(mogg))
                {
                    Tools.ObfM(mogg);
                    ErrorLog.Add("Audio file " + Path.GetFileName(mogg) + " is encrypted and can't be separated, sorry");
                    return(false);
                }
                var ogg = Path.GetTempPath() + "o";
                Tools.RemoveMHeader(mogg, DecryptMode.ToFile, ogg);
                var folder  = Path.GetDirectoryName(mogg) + "\\";
                var bass    = folder + "rhythm.ogg";
                var guitar  = folder + "guitar.ogg";
                var keys    = folder + "keys.ogg";
                var vocals  = folder + "vocals.ogg";
                var backing = folder + "song.ogg";
                var crowd   = folder + "crowd.ogg";
                var drums   = folder + "drums.ogg";
                var drums1  = folder + "drums_1.ogg";
                var drums2  = folder + "drums_2.ogg";
                var drums3  = folder + "drums_3.ogg";
                if (song.ChannelsDrums > 0)
                {
                    switch (song.ChannelsDrums)
                    {
                    case 2:
                        SendToSox(ogg, drums, song.AttenuationValues, 1, true);
                        break;

                    case 3:
                        SendToSox(ogg, drums1, song.AttenuationValues, 1, false);
                        SendToSox(ogg, drums2, song.AttenuationValues, 2, true);
                        break;

                    case 4:
                        SendToSox(ogg, drums1, song.AttenuationValues, 1, false);
                        SendToSox(ogg, drums2, song.AttenuationValues, 2, false);
                        SendToSox(ogg, drums3, song.AttenuationValues, 3, true);
                        break;

                    case 5:
                        SendToSox(ogg, drums1, song.AttenuationValues, 1, false);
                        SendToSox(ogg, drums2, song.AttenuationValues, 2, true);
                        SendToSox(ogg, drums3, song.AttenuationValues, 4, true);
                        break;

                    case 6:
                        SendToSox(ogg, drums1, song.AttenuationValues, 1, true);
                        SendToSox(ogg, drums2, song.AttenuationValues, 3, true);
                        SendToSox(ogg, drums3, song.AttenuationValues, 5, true);
                        break;
                    }
                }
                var index = song.ChannelsDrums + 1;
                if (song.ChannelsBass > 0)
                {
                    SendToSox(ogg, bass, song.AttenuationValues, index, song.ChannelsBass == 2);
                }
                index += song.ChannelsBass;
                if (song.ChannelsGuitar > 0)
                {
                    SendToSox(ogg, guitar, song.AttenuationValues, index, song.ChannelsGuitar == 2);
                }
                index += song.ChannelsGuitar;
                if (song.ChannelsVocals > 0)
                {
                    SendToSox(ogg, vocals, song.AttenuationValues, index, song.ChannelsVocals == 2);
                }
                index += song.ChannelsVocals;
                if (song.ChannelsKeys > 0)
                {
                    SendToSox(ogg, keys, song.AttenuationValues, index, song.ChannelsKeys == 2);
                }
                index += song.ChannelsKeys;
                if (song.ChannelsBacking() > 0)
                {
                    SendToSox(ogg, backing, song.AttenuationValues, index, song.ChannelsBacking() == 2);
                }
                index += song.ChannelsBacking();
                if (song.ChannelsCrowd > 0)
                {
                    SendToSox(ogg, crowd, song.AttenuationValues, index, song.ChannelsCrowd == 2);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }