Beispiel #1
0
        static PROTRACKER_COMPATIBILITY_MODE GetProtrackerCompatibilityMode(string input)
        {
            PROTRACKER_COMPATIBILITY_MODE mode = PROTRACKER_COMPATIBILITY_MODE.A3MAX;

            input = input.ToUpper();

            if (FORCE_PROTRACKER_COMPATIBILITY_AVAILABLE_MODE.Contains(input))
            {
                switch (input.ToCharArray()[0])
                {
                case 'N':
                    mode = PROTRACKER_COMPATIBILITY_MODE.NONE;
                    break;

                case 'S':
                    mode = PROTRACKER_COMPATIBILITY_MODE.B3MAX;
                    break;

                case 'H':
                    mode = PROTRACKER_COMPATIBILITY_MODE.A3MAX;
                    break;
                }
            }
            else
            {
                throw new ApplicationException("Invalid ProTracker Compatibiltiy mode specified");
            }

            return(mode);
        }
Beispiel #2
0
        public ModUtils(SongData songData, int paramTicksPerRow, PROTRACKER_COMPATIBILITY_MODE forceProTrackerCompatibility, int portamentoAccuracyThreshold, bool ntscMode)
            : base(songData, paramTicksPerRow, ntscMode)
        {
            modCommands = new ModCommands(songData, paramTicksPerRow);

            this.forceProtrackerCompatibility = forceProTrackerCompatibility;
            this.portamentoAccuracyThreshold  = portamentoAccuracyThreshold;
            instrumentsList = new InstrumentDataMOD[songData.Instruments.Length];

            for (int i = 0; i < instrumentsList.Length; i++)
            {
                instrumentsList[i]         = new InstrumentDataMOD();
                instrumentsList[i].Samples = new InstrumentDataMOD.SampleDataMOD[songData.Instruments[i].Samples.Length];
                for (int a = 0; a < instrumentsList[i].Samples.Length; a++)
                {
                    instrumentsList[i].Samples[a] = new InstrumentDataMOD.SampleDataMOD();
                }
            }
            for (int i = 0; i < channelData.Length; i++)
            {
                ChannelInfoData item = new ChannelInfoData();
                item.ReachedNote = -1;
                channelData[i]   = item;
            }
        }
Beispiel #3
0
        private void Init(SongData songData)
        {
            const int initialTickPerRow = 6;

            int ticksPerRow = initialTickPerRow;

            PROTRACKER_COMPATIBILITY_MODE forceProTrackerCompatibility = Settings.ForceProTrackerCompatibility;
            int  portamentoAccuracyLossThreshold = Settings.PortamentoLossThreshold;
            bool NtscMode = Settings.NtscMode;

            modUtils = new ModUtils(songData, ticksPerRow, forceProTrackerCompatibility, portamentoAccuracyLossThreshold, NtscMode);
        }
Beispiel #4
0
        public static Stream GetModEncodedSample(int handle, long sampleLength, PROTRACKER_COMPATIBILITY_MODE ptCompatibility)
        {
            byte[] buffer = new byte[sampleLength];

            // total data written to the new byte[] buffer
            int totalDataWritten = Bass.BASS_ChannelGetData(handle, buffer, (int)sampleLength);

            MemoryStream inputSample = new MemoryStream(buffer);

            MemoryStream outputStream = new MemoryStream();

            BinaryReader reader = new BinaryReader(inputSample);

            BinaryWriter writer = new BinaryWriter(outputStream);

            // BASS gives us unsigned 8 bit sample data. we need signed one!

            // Amiga ProTracker compatibility
            // all samples with no loop should begin with two bytes of 0 value (Thanks to Jojo of OpenMPT for the hints)
            if (ptCompatibility != PROTRACKER_COMPATIBILITY_MODE.NONE)
            {
                for (int i = 0; i < 2; i++)
                {
                    byte value = reader.ReadByte();
                    if (value != 128)
                    {
                        writer.Write(0);
                    }
                }

                inputSample.Seek(0, SeekOrigin.Begin);
            }

            for (uint i = 0; i < totalDataWritten; i++)
            {
                short newValue = reader.ReadByte();
                newValue -= 128;
                writer.Write((sbyte)newValue);
            }

            // sample length must be even, because its value is stored divided by 2
            if (outputStream.Length % 2 != 0)
            {
                writer.Write((sbyte)0);
            }

            outputStream.Seek(0, SeekOrigin.Begin);

            return(outputStream);
        }