Ejemplo n.º 1
0
            public SampleAsset(string name, WaveFile wf)
            {
                Name     = name;
                Channels = (byte)wf.Format.ChannelCount;
                Bits     = (byte)wf.Format.BitsPerSample;

                SamplerChunk smpl = wf.FindChunk <SamplerChunk>();

                if (smpl != null)
                {
                    SampleRate = (int)(44100.0 * (1.0 / (smpl.SamplePeriod / 22675.0)));
                    RootKey    = (short)smpl.UnityNote;
                    Tune       = (short)(smpl.PitchFraction * 100);
                    if (smpl.Loops.Length > 0)
                    {
                        if (smpl.Loops[0].Type != SamplerChunk.SampleLoop.LoopType.Forward)
                        {
                            Console.WriteLine("Warning: Loopmode was not supported on asset: " + Name);
                        }
                        LoopStart = smpl.Loops[0].Start;
                        LoopEnd   = smpl.Loops[0].End + smpl.Loops[0].Fraction + 1;
                    }
                }
                else
                {
                    SampleRate = wf.Format.SampleRate;
                }


                SampleRate = wf.Format.SampleRate;
                Data       = wf.Data.RawSampleData;
            }
            public SampleAsset(string name, WaveFile wf)
            {
                Name = name;
                Channels = (byte)wf.Format.ChannelCount;
                Bits = (byte)wf.Format.BitsPerSample;

                SamplerChunk smpl = wf.FindChunk<SamplerChunk>();
                if (smpl != null)
                {
                    SampleRate = (int)(44100.0 * (1.0 / (smpl.SamplePeriod / 22675.0)));
                    RootKey = (short)smpl.UnityNote;
                    Tune = (short)(smpl.PitchFraction * 100);
                    if (smpl.Loops.Length > 0)
                    {
                        if (smpl.Loops[0].Type != SamplerChunk.SampleLoop.LoopType.Forward)
                            Console.WriteLine("Warning: Loopmode was not supported on asset: " + Name);
                        LoopStart = smpl.Loops[0].Start;
                        LoopEnd = smpl.Loops[0].End + smpl.Loops[0].Fraction + 1;
                    }
                }
                else
                {
                    SampleRate = wf.Format.SampleRate;
                }


                SampleRate = wf.Format.SampleRate;
                Data = wf.Data.RawSampleData;
            }
 public SampleDataAsset(string name, WaveFile wave)
 {
     if (name == null)
         throw new ArgumentNullException("An asset must be given a valid name.");
     assetName = name;
     SamplerChunk smpl = wave.FindChunk<SamplerChunk>();
     if (smpl != null)
     {
         sampleRate = (int)(44100.0 * (1.0 / (smpl.SamplePeriod / 22675.0)));
         rootKey = (short)smpl.UnityNote;
         tune = (short)(smpl.PitchFraction * 100);
         if (smpl.Loops.Length > 0)
         {
             //--WARNING ASSUMES: smpl.Loops[0].Type == SamplerChunk.SampleLoop.LoopType.Forward
             loopStart = smpl.Loops[0].Start;
             loopEnd = smpl.Loops[0].End + smpl.Loops[0].Fraction + 1;
         }
     }
     else
     {
         sampleRate = wave.Format.SampleRate;
     }
     byte[] data = wave.Data.RawSampleData;
     if (wave.Format.ChannelCount != audioChannels) //reformat to supported channels
         data = WaveHelper.GetChannelPcmData(data, wave.Format.BitsPerSample, wave.Format.ChannelCount, audioChannels);
     sampleData = PcmData.Create(wave.Format.BitsPerSample, data, true);
     start = 0;
     end = sampleData.Length;
 }
Ejemplo n.º 4
0
        public SampleDataAsset(string name, WaveFile wave)
        {
            if (name == null)
            {
                throw new ArgumentNullException("An asset must be given a valid name.");
            }
            assetName = name;
            SamplerChunk smpl = wave.FindChunk <SamplerChunk>();

            if (smpl != null)
            {
                sampleRate = (int)(44100.0 * (1.0 / (smpl.SamplePeriod / 22675.0)));
                rootKey    = (short)smpl.UnityNote;
                tune       = (short)(smpl.PitchFraction * 100);
                if (smpl.Loops.Length > 0)
                {
                    //--WARNING ASSUMES: smpl.Loops[0].Type == SamplerChunk.SampleLoop.LoopType.Forward
                    loopStart = smpl.Loops[0].Start;
                    loopEnd   = smpl.Loops[0].End + smpl.Loops[0].Fraction + 1;
                }
            }
            else
            {
                sampleRate = wave.Format.SampleRate;
            }
            byte[] data = wave.Data.RawSampleData;
            if (wave.Format.ChannelCount != audioChannels) //reformat to supported channels
            {
                data = WaveHelper.GetChannelPcmData(data, wave.Format.BitsPerSample, wave.Format.ChannelCount, audioChannels);
            }
            sampleData = PcmData.Create(wave.Format.BitsPerSample, data, true);
            start      = 0;
            end        = sampleData.Length;
        }
Ejemplo n.º 5
0
        public SampleDataAsset(string name, WaveFile wave)
        {
            if (name == null)
            {
                throw new ArgumentNullException("An asset must be given a valid name.");
            }
            assetName = name;
            SamplerChunk smpl = wave.FindChunk <SamplerChunk>();

            if (smpl != null)
            {
                sampleRate = (int)(44100.0 * (1.0 / (smpl.SamplePeriod / 22675.0)));
                rootKey    = (short)smpl.UnityNote;
                tune       = (short)(smpl.PitchFraction * 100);
                if (smpl.Loops.Length > 0)
                {
                    CrossPlatformHelper.Assert(smpl.Loops[0].Type == SamplerChunk.SampleLoop.LoopType.Forward, "Warning: Unsupported LoopType in " + assetName);
                    loopStart = smpl.Loops[0].Start;
                    loopEnd   = smpl.Loops[0].End + smpl.Loops[0].Fraction + 1;
                }
            }
            else
            {
                sampleRate = wave.Format.SampleRate;
            }
            sampleData = WaveHelper.GetSampleData(wave, audioChannels);
            start      = 0;
            end        = sampleData.Length;
        }