Load() public method

public Load ( ) : AudioList,
return AudioList,
Ejemplo n.º 1
0
 // Must be colled to setup the class's functionality
 void init()
 {
     // Singleton method returns a bool depending on whether this object is the instance of the class
     if (SingletonUtil.TryInit(ref _instance, this, gameObject, true))
     {
         if (useCustomPaths)
         {
             loader = new AudioLoader(customJSONPath, customAudioPath);
         }
         else
         {
             loader = AudioLoader.Default;
         }
         fileList = loader.Load();
         if (!fileList.AreEventsSubscribed)
         {
             fileList.SubscribeEvents();
         }
         fileList.PopulateGroups();
         initFileDictionary(fileList);
         addAudioEvents();
         subscribeEvents();
         if (isAudioListener)
         {
             addAudioListener();
         }
         preloadFiles(fileList.Files);
         if (playMusicOnInit)
         {
             playMainMusic();
         }
     }
 }
Ejemplo n.º 2
0
        public void ParseSample6()
        {
            Assert.IsTrue(File.Exists(Sample6Path));
            var container = AudioLoader.Load(Sample6Path);

            Assert.NotNull(container);
        }
 // Must be colled to setup the class's functionality
 void Init()
 {
     // Singleton method returns a bool depending on whether this object is the instance of the class
     if (SingletonUtil.TryInit(ref Instance, this, gameObject, true))
     {
         loader   = new AudioLoader(path);
         fileList = loader.Load();
         if (!fileList.AreEventsSubscribed)
         {
             fileList.SubscribeEvents();
         }
         fileList.PopulateGroups();
         InitFileDictionary(fileList);
         AddAudioEvents();
         SubscribeEvents();
         if (isAudioListener)
         {
             AddAudioListener();
         }
         PreloadFiles(fileList.Files);
         // TODO: Enable after tracks have been delivered
         // initCyclingAudio();
         if (playMusicOnInit)
         {
             playMainMusic();
         }
     }
 }
Ejemplo n.º 4
0
    protected void ProcessAudioSource(string path)
    {
        AudioLoader.Load(path, (isOk, clip) =>
        {
            if (!IsDestroy)
            {
                AudioSource src = DependencyComponent as AudioSource;

                Debuger.Assert(src);
                src.clip = clip;
                //src.Play(); // 特效进行Play, 不主动播放
                src.Stop();
            }
            OnFinishLoadDependencies(DependencyComponent); // 返回GameObject而已哦
        });
    }
        public void Sinus100Hz_Spectrum()
        {
            var audioContainer  = AudioLoader.Load(Samples.Wave100hz);
            var spectrumCreator = new SpectrumCreatorCPU(audioContainer);
            var settings        = new SpectrumCreatorSettings(audioContainer)
            {
                SpectrumMinFrequency  = 20,
                SpectrumMaxFrequency  = 20_000,
                SpectrumFrequencyStep = 100
            };
            var spectrumContainer = spectrumCreator.CreateSpectrum(settings);
            var amplitude100      = spectrumContainer.GetSliceForSignal(200).GetAmplitudeForFrequency(100);
            var amplitude50       = spectrumContainer.GetSliceForSignal(200).GetAmplitudeForFrequency(50);
            var amplitude150      = spectrumContainer.GetSliceForSignal(200).GetAmplitudeForFrequency(150);

            Assert.True(amplitude100 > 0.9f);
            Assert.True(amplitude50 < 0.1f);
            Assert.True(amplitude150 > 0.1f);
        }
    }
	// Must be colled to setup the class's functionality
	void Init () {

		// Singleton method returns a bool depending on whether this object is the instance of the class
		if (SingletonUtil.TryInit (ref Instance, this, gameObject)) {
				
			loader = new AudioLoader (path);
			fileList = loader.Load ();
			fileList.Init ();

			InitFileDictionary (fileList);

			AddAudioEvents ();

			SubscribeEvents ();

			if (isAudioListener) {
				AddAudioListener ();
			}
			initCyclingAudio ();
	
		} else { 
			//this = Instance;
		}
	}
Ejemplo n.º 7
0
        protected internal override SoundEffect Read(
            ContentReader input, SoundEffect existingInstance)
        {
            #region Old XNA spec
            // XNB format for SoundEffect...
            //
            // Byte [format size]	Format	WAVEFORMATEX structure
            // UInt32	Data size
            // Byte [data size]	Data	Audio waveform data
            // Int32	Loop start	In bytes (start must be format block aligned)
            // Int32	Loop length	In bytes (length must be format block aligned)
            // Int32	Duration	In milliseconds

            // The header containss the WAVEFORMATEX header structure
            // defined as the following...
            //
            //  WORD  wFormatTag;       // byte[0]  +2
            //  WORD  nChannels;        // byte[2]  +2
            //  DWORD nSamplesPerSec;   // byte[4]  +4
            //  DWORD nAvgBytesPerSec;  // byte[8]  +4
            //  WORD  nBlockAlign;      // byte[12] +2
            //  WORD  wBitsPerSample;   // byte[14] +2
            //  WORD  cbSize;           // byte[16] +2
            #endregion
            // We let the sound effect deal with parsing this based
            // on what format the audio data actually is.

            int    headerSize = input.ReadInt32();
            byte[] header     = input.ReadBytes(headerSize);

            int loopStart  = input.ReadInt32();
            int loopLength = input.ReadInt32();
            var duration   = input.ReadObject <TimeSpan>();

            SoundEffect effect;
            int         rawSize = input.ReadInt32();
            short       format  = BinaryPrimitives.ReadInt16LittleEndian(header);

            SoundEffect CreateSoundEffect(RecyclableBuffer buffer)
            {
                var data = buffer.AsSpan(0, buffer.BaseLength);

                return(new SoundEffect(header, data, duration, loopStart, loopLength)
                {
                    // Store the original asset name for debugging later.
                    Name = input.AssetName
                });
            }

            if (format == 1)
            {
                using (var data = AudioLoader.Load(
                           input.BaseStream, out ALFormat alFormat, out _, out _, out _, out _, out _, out _))
                {
                    if (alFormat == ALFormat.MonoFloat32 || alFormat == ALFormat.StereoFloat32)
                    {
                        BinaryPrimitives.WriteInt16LittleEndian(header, 3);
                    }

                    // data gets uploaded synchronously
                    effect = CreateSoundEffect(data);
                }
            }
            else
            {
                using (var data = RecyclableBuffer.ReadBytes(
                           input.BaseStream, rawSize, nameof(SoundEffectReader)))
                    effect = CreateSoundEffect(data);
            }

            return(effect);
        }
Ejemplo n.º 8
0
	void init () {

		if (SingletonUtil.TryInit(ref _instance, this, gameObject)) {
				
			_loader = new AudioLoader(PATH);
			_fileList = _loader.Load();

			initFileDictionary(_fileList);

			addAudioEvents();

			subscribeEvents();

		}
	}