コード例 #1
0
ファイル: SampleLoader.cs プロジェクト: VRDate/sharpmod
 ///<summary>
 ///</summary>
 ///<param name="reader"></param>
 ///<param name="inputFormat"></param>
 ///<param name="outputFormat"></param>
 public virtual void Init(ModBinaryReader reader, SampleFormatFlags inputFormat, SampleFormatFlags outputFormat)
 {
     _old          = 0;
     _reader       = reader;
     _inputFormat  = inputFormat;
     _outputFormat = outputFormat;
 }
コード例 #2
0
 public SampleFormatInfo(
     SampleFormat id,
     int bitCount,
     Type type,
     SampleFormatFlags flags = default)
 {
     Id       = id;
     BitCount = bitCount;
     Type     = type;
     Flags    = flags;
 }
コード例 #3
0
ファイル: ModuleLoader.cs プロジェクト: VRDate/sharpmod
        /// <summary>
        /// Load Sample from the Module Stream
        /// </summary>
        /// <param name="length">Length in bytes of the sample</param>
        /// <param name="reppos">Repeat begin position</param>
        /// <param name="repend">Repeat end position</param>
        /// <param name="flags">Sample format flags</param>
        /// <returns>Handle of the sample</returns>
        public short SampleLoad(int length, int reppos, int repend, SampleFormatFlags flags)
        {
            // Find empty slot to put sample address in
            var handle = _samples.Count;

            _sampleLoader.Init(_reader, flags, ((flags | (SampleFormatFlags.SF_SIGNED)) & ~(SampleFormatFlags.SF_16BITS)));

            // create the new byte array entry
            _samples.Add(new byte[length + 17]);

            // read sample into buffer.
            LargeRead(_samples[handle], length);

            // Unclick samples:
            if ((flags & (SampleFormatFlags.SF_LOOP)) != 0)
            {
                if ((flags & (SampleFormatFlags.SF_BIDI)) != 0)
                {
                    for (var t = 0; t < 16; t++)
                    {
                        _samples[handle][repend + t] = _samples[handle][(repend - t) - 1];
                    }
                }
                else
                {
                    for (var t = 0; t < 16; t++)
                    {
                        _samples[handle][repend + t] = _samples[handle][t + reppos];
                    }
                }
            }
            else
            {
                for (int t = 0; t < 16; t++)
                {
                    _samples[handle][t + length] = 0;
                }
            }

            return((short)handle);
        }