示例#1
0
        public static void Execute(string aFilePathOutput, LoopInformation aLoopInformation)
        {
            RiffWaveRiff lRiffWaveRiff = ( RiffWaveRiff )PoolCollection.GetRiffWave(aFilePathOutput);

            WaveformReaderPcm waveform = new WaveformReaderPcm(lRiffWaveRiff, true);

            OverrideCuePoint(lRiffWaveRiff, ( int )aLoopInformation.start.sample, ( int )aLoopInformation.end.sample);
            OverrideSampleLoop(lRiffWaveRiff, ( int )aLoopInformation.start.sample, ( int )aLoopInformation.end.sample);

            Byte[]       lDataArrayRead = null;
            RiffWaveData dataChunk      = ( RiffWaveData )lRiffWaveRiff.GetChunk(RiffWaveData.ID);

            using (FileStream u = new FileStream(lRiffWaveRiff.name, FileMode.Open, FileAccess.Read))
            {
                AByteArray l = new ByteArrayLittle(u);

                int bytePosition = ( int )dataChunk.position;

                l.SetPosition(bytePosition);

                lDataArrayRead = l.ReadBytes(dataChunk.Size);
            }

            Byte[] lDataArrayWrite = lDataArrayRead;

            if (IsCutLast == true)
            {
                int lLength = ( int )(aLoopInformation.end.sample + 1) * waveform.format.channels * (waveform.format.sampleBits / 8);
                Logger.BreakDebug("End:" + aLoopInformation.end.sample);

                lDataArrayWrite = new Byte[lLength];

                for (int i = 0; i < lLength; i++)
                {
                    lDataArrayWrite[i] = lDataArrayRead[i];
                }
            }

            SetDataArray(lRiffWaveRiff, lDataArrayWrite);

            MemoryStream    lMemoryStreamWrite = new MemoryStream(( int )lRiffWaveRiff.Size + 8);
            ByteArrayLittle lByteArray         = new ByteArrayLittle(lMemoryStreamWrite);

            lRiffWaveRiff.WriteByteArray(lByteArray);

            Logger.BreakDebug("WriteByteArray");
            Logger.BreakDebug("Out:" + aFilePathOutput);

            try
            {
                using (FileStream u = new FileStream(aFilePathOutput, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    u.Write(lMemoryStreamWrite.GetBuffer(), 0, ( int )lMemoryStreamWrite.Length);
                }
            }
            catch (Exception aExpection)
            {
                Logger.BreakError("Write Exception:" + aExpection);
            }
        }
示例#2
0
    public static void GenerateEnumTags(PoolCollection poolCollection)
    {
        var path = $"{Application.dataPath}/Scripts/PoolingSystem/Tags";

        if (!System.IO.Directory.Exists(path))
        {
            System.IO.Directory.CreateDirectory(path);
        }

        path = $"{path}/TAGS_{poolCollection.name}.cs";

        using (StreamWriter outFile = new StreamWriter(path))
        {
            outFile.WriteLine($"public enum {poolCollection.name}Tags");
            outFile.WriteLine("{");

            foreach (var pool in poolCollection.PrefabPoolsList)
            {
                outFile.WriteLine($"    {pool.Tag},");
            }

            outFile.WriteLine("}");
        }

        AssetDatabase.Refresh();
    }
        public void CtorWithComparer()
        {
            EqualityComparer <Target> comparer = EqualityComparer <Target> .Default;
            var pool = new PoolCollection <Target>(comparer);

            Assert.AreEqual(comparer, pool.Comparer);
        }
        public void DisabledCount()
        {
            var pool = new PoolCollection <Target>();

            pool.Add(new Target());

            Assert.AreEqual(1, pool.DisabledCount);
        }
        public void Enabled()
        {
            var pool = new PoolCollection <Target>();

            pool.Add(new Target());
            pool.Enable();

            int count = pool.Enabled.Count();

            Assert.AreEqual(1, count);
        }
        public void IsDisabled()
        {
            var pool   = new PoolCollection <Target>();
            var target = new Target();

            pool.Add(target);

            bool result0 = pool.IsDisabled(target);

            Assert.True(result0);
        }
示例#7
0
        /// <summary>
        /// Gets a PoolCollection. Use for diagnostics, debug printing.
        /// </summary>
        public static PoolCollection <T> FindCollection <T>()
        {
            object obj;

            if (!directory.TryGetValue(typeof(T), out obj))
            {
                obj = new PoolCollection <T>();
                directory.Add(typeof(T), obj);
            }

            return((PoolCollection <T>)obj);
        }
        public void CtorWithCollection()
        {
            var collection = new List <Target> {
                new Target(), new Target()
            };
            var pool = new PoolCollection <Target>(collection);

            Assert.AreEqual(2, pool.Count);
            Assert.AreEqual(0, pool.EnabledCount);
            Assert.AreEqual(2, pool.DisabledCount);
            Assert.AreSame(EqualityComparer <Target> .Default, pool.Comparer);
        }
示例#9
0
    public static void ManagePoolCollection(PoolCollection poolCollection)
    {
        // make sure we can safely add the bin!
        if (instance._poolNameToInstanceId.ContainsKey(poolCollection.prefab.name)) {
            Debug.LogError( "Cannot manage the pool because there is already a GameObject with the name (" + poolCollection.prefab.name + ") being managed" );
            return;
        }

        instance.poolCollection.Add(poolCollection);
        poolCollection.Initialize();
        instance._instanceIdToPoolCollection.Add(poolCollection.prefab.GetInstanceID(), poolCollection);
        instance._poolNameToInstanceId.Add(poolCollection.prefab.name, poolCollection.prefab.GetInstanceID());
    }
        public void Remove()
        {
            var pool   = new PoolCollection <Target>();
            var target = new Target();

            pool.Add(target);

            Target result0 = pool.Remove();

            Assert.NotNull(result0);
            Assert.AreSame(result0, target);
            Assert.AreEqual(0, pool.Count);
        }
        public void Contains()
        {
            var pool   = new PoolCollection <Target>();
            var target = new Target();

            pool.Add(target);

            bool result0 = pool.Contains(target);
            bool result1 = pool.Contains(null);

            Assert.True(result0);
            Assert.False(result1);
        }
        public void Disable()
        {
            var pool   = new PoolCollection <Target>();
            var target = new Target();

            pool.Add(target);
            pool.Enable();

            bool result0 = pool.Disable(target);

            Assert.True(result0);
            Assert.AreEqual(1, pool.Count);
            Assert.AreEqual(0, pool.EnabledCount);
            Assert.AreEqual(1, pool.DisabledCount);
        }
示例#13
0
        public SoundfontSfz(SfzRegion sfzData)
        {
            byte  lokey          = sfzData.lokey;
            byte  hikey          = sfzData.hikey;
            bool  loopMode       = sfzData.loop_mode;
            int   loopStart      = sfzData.loop_start - 1;
            int   loopEnd        = sfzData.loop_end;
            int   offset         = sfzData.offset;
            int   end            = sfzData.end;
            int   tune           = sfzData.tune;
            int   pitchKeyCenter = sfzData.pitch_keycenter;
            float volume         = sfzData.volume;

            soundinfo = new Soundinfo(lokey, hikey, loopMode, loopStart, loopEnd, offset, end, tune, pitchKeyCenter, 0, 0, volume);
            ampeg     = new Ampeg(sfzData.ampeg_delay, sfzData.ampeg_start / 100.0f, sfzData.ampeg_attack, sfzData.ampeg_hold, sfzData.ampeg_decay, sfzData.ampeg_sustain / 100.0f, sfzData.ampeg_release);

            waveform = new WaveformReaderPcm(PoolCollection.GetRiffWave(sfzData.sample), true);
        }
        public void DisableAll()
        {
            var pool = new PoolCollection <Target>();

            for (int i = 0; i < 5; i++)
            {
                pool.Add(new Target());
                pool.Enable();
            }

            Assert.AreEqual(5, pool.Count);
            Assert.AreEqual(5, pool.EnabledCount);
            Assert.AreEqual(0, pool.DisabledCount);

            pool.DisableAll();

            Assert.AreEqual(5, pool.Count);
            Assert.AreEqual(0, pool.EnabledCount);
            Assert.AreEqual(5, pool.DisabledCount);
        }
示例#15
0
    public void CreateNewPoolCollection()
    {
        var asset = ScriptableObject.CreateInstance <PoolCollection>();

        if (!AssetDatabase.IsValidFolder("Assets/PoolCollections"))
        {
            AssetDatabase.CreateFolder("Assets", "PoolCollections");
        }

        var uniqueFileName = AssetDatabase.GenerateUniqueAssetPath("Assets/PoolCollections/PoolCollection.asset");

        AssetDatabase.CreateAsset(asset, uniqueFileName);
        AssetDatabase.SaveAssets();

        EditorUtility.FocusProjectWindow();

        //Selection.activeObject = asset;

        this._poolCollection = asset;

        CleanScriptableObjectsInstances();
    }
示例#16
0
 public MusicWave(string aPathFile)
     : base(PoolCollection.GetRiffWave(aPathFile))
 {
 }
示例#17
0
 public MusicAiff(string aPathFile)
     : base(PoolCollection.GetFormAiff(aPathFile))
 {
 }
示例#18
0
    private void addRecycleBin( GameObject go )
    {
        if(_poolManTarget.poolCollection == null) {
            _poolManTarget.poolCollection = new List<PoolCollection>();
        }

        if(_poolManTarget.poolCollection != null) {
            foreach( var recycleBin in _poolManTarget.poolCollection )
            {
                if( recycleBin.prefab.gameObject.name == go.name )
                {
                    EditorUtility.DisplayDialog( "Pool Man", "Pool Man already manages a GameObject with the name '" + go.name + "'.\n\nIf you are attempting to manage multiple GameObjects sharing the same name, you will need to first give them unique names.", "OK" );
                    return;
                }
            }
        }

        PoolCollection newPrefabPool = new PoolCollection();
        newPrefabPool.prefab = go;

        _poolManTarget.poolCollection.Add(newPrefabPool);
        while(_poolManTarget.poolCollection.Count > _prefabFoldouts.Count) {
            _prefabFoldouts.Add(false);
        }
    }
示例#19
0
		public static void Execute( string aFilePathInput, string aFilePathOutput, InputMusicInformation aData )
		{
			RiffWaveRiff lRiffWaveRiff = ( RiffWaveRiff )PoolCollection.GetRiffWave( aFilePathInput );

			WaveformPcm lWaveform = new WaveformPcm( lRiffWaveRiff );

			SByte[] lSampleArray = new SByte[lWaveform.format.samples];
			
			lSampleArray = lWaveform.data.sampleByteArray[0];

			List<LoopInformation> lLoopList = null;

			try
			{
				if( lWaveform.format.samples > 44100 * 16 )
				{
					lLoopList = LoopSearchTool.Execute( lSampleArray, aData, aFilePathInput );
				}
				else
				{
					lLoopList = LoopSearchToolSoundfont.Execute( lSampleArray, aData, aFilePathInput );
				}
			}
			catch( Exception aExpection )
			{
				Logger.BreakError( aExpection.ToString() + ":LoopTool Exception" );
			}

			for( int i = 0; i < lLoopList.Count; i++ )
			{
				AddCuePoint( lRiffWaveRiff, ( int )lLoopList[i].start.sample, ( int )lLoopList[i].end.sample );
				AddSampleLoop( lRiffWaveRiff, ( int )lLoopList[i].start.sample, ( int )lLoopList[i].end.sample );
			}

			Byte[] lDataArrayRead = null;
			RiffWaveData dataChunk = ( RiffWaveData )lRiffWaveRiff.GetChunk( RiffWaveData.ID );
			
			using ( FileStream u = new FileStream( lRiffWaveRiff.name, FileMode.Open, FileAccess.Read ) )
			{
				AByteArray l = new ByteArrayLittle( u );
				
				int bytePosition = ( int )dataChunk.position;

				l.SetPosition( bytePosition );
				
				lDataArrayRead = l.ReadBytes( dataChunk.Size );
			}

			SetDataArray( lRiffWaveRiff, lDataArrayRead );
			
			Logger.BreakDebug( "lMemoryStreamWrite" );

			MemoryStream lMemoryStreamWrite = new MemoryStream( ( int )lRiffWaveRiff.Size + 8 );
			ByteArrayLittle lByteArray = new ByteArrayLittle( lMemoryStreamWrite );

			lRiffWaveRiff.WriteByteArray( lByteArray );
			
			Logger.BreakDebug( "WriteByteArray" );
			Logger.BreakDebug( "Out:" + aFilePathOutput );
			
			try
			{
				using( FileStream u = new FileStream( aFilePathOutput, FileMode.Create, FileAccess.Write, FileShare.Read ) )
				{
					u.Write( lMemoryStreamWrite.GetBuffer(), 0, ( int )lMemoryStreamWrite.Length );
				}
			}
			catch( Exception aExpection )
			{
				Logger.BreakError( "Write Exception:" + aExpection );
			}
		}