public void PlaySound(TypeAudio type)
 {
     if (!isMute)
     {
         audioDict[type].Play();
     }
 }
示例#2
0
        public static Bytes TransitionAudioFrame(Bytes aAudioSamples, TypeAudio eTransitionType, float nProgress)
        {
            switch (eTransitionType)
            {
            case TypeAudio.cut:
                if (nProgress < 0.5)
                {
                    return(aAudioSamples);
                }
                else
                {
                    return(null);
                }

            case TypeAudio.crossfade:
                short nCoeff;
                for (int nByteIndx = 0; nByteIndx < aAudioSamples.Length; nByteIndx += 2)
                {
                    nCoeff = (short)((aAudioSamples.aBytes[nByteIndx + 1] << 8) + aAudioSamples.aBytes[nByteIndx]);
                    nCoeff = (short)(nCoeff * (1 - nProgress));
                    aAudioSamples.aBytes[nByteIndx]     = (byte)nCoeff;
                    aAudioSamples.aBytes[nByteIndx + 1] = (byte)(nCoeff >> 8);
                }
                break;

            default:
                throw new NotImplementedException("unknown audio transition type");
            }
            return(aAudioSamples);
        }
    public void Awake()
    {
        // in case play is called early.
        textLabel = GetComponent <TextMeshProUGUI>();
        typeSound = GetComponent <TypeAudio>();

        textLabel.maxVisibleCharacters = 0;
    }
        public void PlayAudio(TypeAudio typeAudio)
        {
            foreach (var audioItem in audioItems)
            {
                if (audioItem.TypeAudio == typeAudio)
                {
                    audioSource.clip = audioItem.AudioClip;
                }
            }

            audioSource.Play();
        }
示例#5
0
        private byte[] TransitionAudioFrame(byte[] aAudioSamples, TypeAudio eTransitionType, float nProgress)
        {
			switch (eTransitionType)
            {
                case TypeAudio.cut:
                        if (nProgress < 0.5)
                        {
                            return aAudioSamples;
                        }
                        else
                            return null;
                case TypeAudio.crossfade:
						short nCoeff;
                        for (int nByteIndx = 0; nByteIndx < aAudioSamples.Length; nByteIndx += 2)
                        {
                            nCoeff = (short)((aAudioSamples[nByteIndx + 1] << 8) + aAudioSamples[nByteIndx]);
                            nCoeff = (short)(nCoeff * (1 - nProgress));
                            aAudioSamples[nByteIndx] = (byte)nCoeff;
                            aAudioSamples[nByteIndx + 1] = (byte)(nCoeff >> 8);
                        }
                        break;
                default:
						throw new NotImplementedException("unknown audio transition type");
            }
            return aAudioSamples;
        }