void load_sound(SOUND_TYPE t) { if (audio_controller.sound_isplaying != 1) { return; } AudioClip clip = null; switch (t) { case SOUND_TYPE.hit: clip = Resources.Load <AudioClip>("sound/enemy_hit"); break; case SOUND_TYPE.dead: clip = Resources.Load <AudioClip>("sound/enemy_dead_2"); break; case SOUND_TYPE.bullet: clip = Resources.Load <AudioClip>("sound/bullet"); break; } audio.PlayOneShot(clip); }
public void Play(SOUND_TYPE st) { if (!enable) { return; } switch (st) { case SOUND_TYPE.PICK: //if(!click.isPlaying) click.Play(); break; case SOUND_TYPE.ERROR: error.Play(); break; case SOUND_TYPE.QUIZ: quiz.Play(); break; default: Debug.LogError("Unkown sound type"); break; } }
public void PlayFXSound(SOUND_TYPE type) { if (PlayerData.Instance.SoundEnable == true) { mFxAudio.clip = mFxSound[(int)type]; mFxAudio.Play(); } }
private void populateStats() { float fZero = 0; int iZero = 0; SOUND_TYPE type = SOUND_TYPE.RAW; SOUND_FORMAT format = SOUND_FORMAT.NONE; _channel.Sound.getFormat(ref type, ref format, ref channels, ref bits); _channel.Sound.getLength(ref lengthPcmBytes, TIMEUNIT.PCMBYTES); _channel.Sound.getDefaults(ref freq, ref fZero, ref fZero, ref iZero); }
public void PlayOneShot(AudioClip clip, float volume, SOUND_TYPE type) { if (clip == null) { clip = _defaultClip; } if (null != _subAudio && clip != null) { PlayOneShot(_subAudio, clip, volume, type); } }
//.wavのヘッダーを入力 static uint WriteHeader(FileStream SubSoundStream, Sound SubSound) { uint Milliseconds = 0; uint RAWBytes = 0; uint PCMBytes = 0; uint Length = 0; //音の情報を取得 SubSound.getLength(ref Milliseconds, TIMEUNIT.MS); SubSound.getLength(ref RAWBytes, TIMEUNIT.RAWBYTES); SubSound.getLength(ref PCMBytes, TIMEUNIT.PCMBYTES); SubSoundStream.Seek(0, SeekOrigin.Begin); float Frequency = 0f; int DefPriority = 0; float DefPan = 0; float DefVolume = 0; SOUND_TYPE FModSoundType = new SOUND_TYPE(); SOUND_FORMAT FModSoundFormat = new SOUND_FORMAT(); int Channels = 0; int BitsPerSample = 0; SubSound.getDefaults(ref Frequency, ref DefVolume, ref DefPan, ref DefPriority); SubSound.getFormat(ref FModSoundType, ref FModSoundFormat, ref Channels, ref BitsPerSample); int BlockAlign = (Channels * BitsPerSample) / 8; float DataRate = (Channels * Frequency * BitsPerSample) / 8; uint PCMSamples = Convert.ToUInt32(Milliseconds * Frequency / 1000); if (Channels == 2) { Length = Convert.ToUInt32(PCMSamples * Channels * (BitsPerSample / 8)); } else { Length = PCMBytes * 2; } //詳しくはこちらをお読みください。http://www.topherlee.com/software/pcm-tut-wavformat.html //最初の4バイトは必ず"RIFF" SubSoundStream.Write(Encoding.ASCII.GetBytes("RIFF"), 0, 4); SubSoundStream.Write(BitConverter.GetBytes((long)0), 0, 4); SubSoundStream.Write(Encoding.ASCII.GetBytes("WAVEfmt "), 0, 8); SubSoundStream.Write(BitConverter.GetBytes((long)16), 0, 4); SubSoundStream.Write(BitConverter.GetBytes((int)1), 0, 2); SubSoundStream.Write(BitConverter.GetBytes((int)2), 0, 2); SubSoundStream.Write(BitConverter.GetBytes((long)Frequency), 0, 4); SubSoundStream.Write(BitConverter.GetBytes((int)DataRate), 0, 4); SubSoundStream.Write(BitConverter.GetBytes(BlockAlign), 0, 2); SubSoundStream.Write(BitConverter.GetBytes(BitsPerSample), 0, 2); SubSoundStream.Write(Encoding.ASCII.GetBytes("data"), 0, 4); SubSoundStream.Write(BitConverter.GetBytes((long)Length), 0, 4); return(Length); }
public RESULT getFormat(ref SOUND_TYPE type, ref SOUND_FORMAT format, ref int channels, ref int bits) { RESULT result; if (VERSION.platform == Platform.X64) { result = Sound.FMOD_Sound_GetFormat_64(soundraw, ref type, ref format, ref channels, ref bits); } else { result = Sound.FMOD_Sound_GetFormat_32(soundraw, ref type, ref format, ref channels, ref bits); } return(result); }
// Returns the volume that matches the sound type. public float GetVolume(SOUND_TYPE type) { float result = 1; if (type == SOUND_TYPE.BGM) { result = GetBGMVolumeNormalized(); } else if (type == SOUND_TYPE.SFX) { result = GetSFXVolumeNormalized(); } return(result); }
void load_sound(SOUND_TYPE t) { if (audio_controller.sound_isplaying != 1) { return; } AudioClip clip = null; switch (t) { case SOUND_TYPE.state_1: clip = Resources.Load<AudioClip>("sound/ice_1"); break; case SOUND_TYPE.state_2: clip = Resources.Load<AudioClip>("sound/ice_2"); break; } audio.PlayOneShot(clip); }
// 音量調整メソッド public void SetVolume(SOUND_TYPE soundType, float volume) { switch (soundType) { case SOUND_TYPE.BGM: bgmPlayer.SetVolume(volume); break; case SOUND_TYPE.SE: sePlayer.SetVolume(volume); break; case SOUND_TYPE.VOICE: voicePlayer.SetVolume(volume); break; } }
// サウンド停止メソッド public void Stop(SOUND_TYPE soundType) { switch (soundType) { case SOUND_TYPE.BGM: bgmPlayer.Stop(); break; case SOUND_TYPE.SE: sePlayer.AllStop(); break; case SOUND_TYPE.VOICE: voicePlayer.AllStop(); break; } }
// サウンド再生用メソッド(BGMの時のみループ指定、デフォではfalse) public void Play(SOUND_TYPE soundType, string fileName, bool loop = false) { switch (soundType) { case SOUND_TYPE.BGM: bgmPlayer.Play(fileName, loop); break; case SOUND_TYPE.SE: sePlayer.Play(fileName); break; case SOUND_TYPE.VOICE: voicePlayer.Play(fileName); break; } }
public void PlayBackSound(SOUND_TYPE _selectSound) { switch (_selectSound) { case SOUND_TYPE.SOUND_TYPE_ATTACH: _audio.PlayOneShot(_attachSound); break; case SOUND_TYPE.SOUND_TYPE_FAILUR: _audio.PlayOneShot(_failurSound); break; case SOUND_TYPE.SOUND_TYPE_GET: _audio.PlayOneShot(_getSound); break; } }
// サウンド読み込みメソッド public void Load(SOUND_TYPE soundType, string fileName) { switch (soundType) { case SOUND_TYPE.BGM: bgmPlayer.Load(fileName); break; case SOUND_TYPE.SE: sePlayer.Load(fileName); break; case SOUND_TYPE.VOICE: voicePlayer.Load(fileName); break; } }
void load_sound(SOUND_TYPE t) { if (audio_controller.sound_isplaying != 1) { return; } AudioClip clip = null; switch (t) { case SOUND_TYPE.dead: clip = Resources.Load<AudioClip>("sound/enemy_dead_1"); break; case SOUND_TYPE.hit: clip = Resources.Load<AudioClip>("sound/enemy_hit"); break; case SOUND_TYPE.move: clip = Resources.Load<AudioClip>("sound/move"); break; } audio.PlayOneShot(clip); }
void load_sound(SOUND_TYPE t) { if (audio_controller.sound_isplaying != 1) { return; } AudioClip clip = null; switch (t) { case SOUND_TYPE.state_1: clip = Resources.Load <AudioClip>("sound/ice_1"); break; case SOUND_TYPE.state_2: clip = Resources.Load <AudioClip>("sound/ice_2"); break; } audio.PlayOneShot(clip); }
public void PlayOneShot(AudioSource source, AudioClip clip, float volume, SOUND_TYPE type) { SetVolume(source, volume, type); source.PlayOneShot(clip, GetVolume(type)); }
private static extern RESULT FMOD5_Sound_GetFormat (IntPtr sound, out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits);
public void Play(AudioSource source, float desiredVolume, SOUND_TYPE type) { SetVolume(source, desiredVolume, type); source.Play(); }
public void SetVolume(AudioSource source, float desiredVolume, SOUND_TYPE type) { source.volume = GetVolume(type) * desiredVolume; }
public void UnpauseAudio(AudioSource source, float desiredVolume, SOUND_TYPE type) { SetVolume(source, desiredVolume, type); source.UnPause(); }
private static extern RESULT FMOD5_Sound_GetFormat(IntPtr sound, out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits);
public RESULT getFormat(out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits) { return(FMOD5_Sound_GetFormat(handle, out type, out format, out channels, out bits)); }
public RESULT getFormat(ref SOUND_TYPE type, ref SOUND_FORMAT format, ref int channels, ref int bits) { return FMOD_Sound_GetFormat(soundraw, ref type, ref format, ref channels, ref bits); }
void load_sound(SOUND_TYPE sound_t) { if (audio_controller.sound_isplaying != 1 ) { return; } AudioClip clip = null; switch (sound_t) { case SOUND_TYPE.barell: clip = Resources.Load<AudioClip>("sound/barrel"); enu_audio.clip = clip; enu_audio.PlayOneShot(clip); break; case SOUND_TYPE.mental: clip = Resources.Load<AudioClip>("sound/hit_mental"); enu_audio.clip = clip; enu_audio.PlayOneShot(clip); break; case SOUND_TYPE.standby: clip = Resources.Load<AudioClip>("sound/panda_standby"); panda_audio.clip = clip; panda_audio.PlayOneShot(clip); break; case SOUND_TYPE.move: clip = Resources.Load<AudioClip>("sound/move"); enu_audio.clip = clip; enu_audio.PlayOneShot(clip); break; case SOUND_TYPE.sitck: clip = Resources.Load<AudioClip>("sound/panda_stick"); enu_audio.clip = clip; enu_audio.PlayOneShot(clip); break; case SOUND_TYPE.dead: clip = Resources.Load<AudioClip>("sound/panda_dead"); panda_audio.clip = clip; panda_audio.PlayOneShot(clip); break; } }
public RESULT getFormat(out SOUND_TYPE t, out SOUND_FORMAT f, out int nch, out int bits) => throw new NotImplementedException();
private static extern RESULT FMOD_Sound_GetFormat_64(IntPtr sound, ref SOUND_TYPE type, ref SOUND_FORMAT format, ref int channels, ref int bits);
public void PlayDelay(AudioSource source, float delay, float volume, SOUND_TYPE type) { SetVolume(source, volume, type); source.PlayDelayed(delay); }
public RESULT getFormat (out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits) { return FMOD_Sound_GetFormat(rawPtr, out type, out format, out channels, out bits); }
public RESULT getFormat(out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits) { return(Sound.FMOD5_Sound_GetFormat(this.rawPtr, out type, out format, out channels, out bits)); }
private static extern RESULT FMOD_Sound_GetFormat(IntPtr sound, ref SOUND_TYPE type, ref SOUND_FORMAT format, ref int channels, ref int bits);
static uint WriteHeader(FileStream SubSoundStream, FMOD.Sound SubSound, string FSBFileStr) { uint Milliseconds = 0; uint RAWBytes = 0; uint PCMBytes = 0; uint PCMSamples = 0; uint Length = 0; SubSound.getLength(ref Milliseconds, TIMEUNIT.MS); // Get the length of the current wave file SubSound.getLength(ref RAWBytes, TIMEUNIT.RAWBYTES); // Get the length of the current wave file SubSound.getLength(ref PCMSamples, TIMEUNIT.PCM); // Get the length of the current wave file SubSound.getLength(ref PCMBytes, TIMEUNIT.PCMBYTES); // Get the length of the current wave file // Seek to the beginning of our newly created output file SubSoundStream.Seek(0, SeekOrigin.Begin); float Frequency = 0f; // Set some default values that aren't very int DefPriority = 0; // important because they'll get overwritten float DefPan = 0; float DefVolume = 0; FMOD.SOUND_TYPE FModSoundType = new SOUND_TYPE(); FMOD.SOUND_FORMAT FModSoundFormat = new SOUND_FORMAT(); int Channels = 0; int BitsPerSample = 0; // Get the default Frequency (important), and other stuff (not important) SubSound.getDefaults(ref Frequency, ref DefVolume, ref DefPan, ref DefPriority); // Get the actual sound format. We pretty much ignore this data since we know its going to be WAV, RIFF, PCM SubSound.getFormat(ref FModSoundType, ref FModSoundFormat, ref Channels, ref BitsPerSample); //Console.WriteLine(" MS={0}\tRAWBytes={1}\tPCMSamples={2}\tPCMBytes={3}", Milliseconds, RAWBytes, PCMSamples, PCMBytes); //Console.WriteLine(" Freq={0}\tChan={1}", Frequency, Channels); if (Switches.Contains("/doublefreq")) { if (Channels == 1) { Frequency = Frequency * 2; } } int BlockAlign = Channels * (BitsPerSample / 8); float DataRate = Channels * Frequency * (BitsPerSample / 8); PCMSamples = Convert.ToUInt32(Milliseconds * Frequency / 1000); // This is more of a sloppy hack. I don't know if I am just reading the file incorrectly, or using the wrong // version of the API, or the FSB files are incorrectly structured, but the metadata that comes from the file // seems to be incorrect. According to the WAV/RIFF specification and the FMOD API Documentation the // following line should be the correct computation. If you use just the following line you get a random // blip at the end of the sounds for the voice overs and the SFX don't play at all. A annoying // trial-and-error process revealed that the logic below works properly. I wish there was a better way to // identify which file we're parsing other than "SFX" in the name. // "Correct" Computation: Length = Convert.ToUInt32(PCMSamples * Channels * (BitsPerSample / 8)); if (Path.GetFileName(FSBFileStr).Contains("VOBank")) { // If we're parsing the VOBank FSB if (Channels == 2) { // Works for the Character Speech FSBs Length = Convert.ToUInt32(PCMSamples * Channels * (BitsPerSample / 8)); } else { Length = PCMBytes * 2; } } else { // If we're parsing a SFX FSB if (Channels == 2) { // Works for the SFX FSBs Length = PCMBytes; } else { //Length = Convert.ToUInt32(PCMSamples * Channels * (BitsPerSample / 8)); //Console.WriteLine(" CustomLen={0}\tPCMBytes={1}\tDiff={2}", Convert.ToUInt32(PCMSamples * Channels * (BitsPerSample / 8)), PCMBytes, (Convert.ToUInt32(PCMSamples * Channels * (BitsPerSample / 8)) - PCMBytes) * 1.0 / PCMBytes * 1.0); if (Switches.Contains("/doublelen")) { Length = PCMBytes * 2; } else { Length = PCMBytes; } } } // Some debugging outputs: //Console.WriteLine(" MS={0}\tRAWBytes={1}\tPCMSamples={2}\tPCMBytes={3}", Milliseconds, RAWBytes, PCMSamples, PCMBytes); //Console.WriteLine(" Freq={0}\tChan={1}\tBits/Sam={2}\tDataRate={3}", Frequency, Channels, BitsPerSample, DataRate); // WAVE RIFF Format: http://www.topherlee.com/software/pcm-tut-wavformat.html // Write the actual specification to the header of the file. SubSoundStream.Write(BitConverter.GetBytes('R'), 0, 1); // 0 - Letter R SubSoundStream.Write(BitConverter.GetBytes('I'), 0, 1); // 1 - Letter I SubSoundStream.Write(BitConverter.GetBytes('F'), 0, 1); // 2 - Letter F SubSoundStream.Write(BitConverter.GetBytes('F'), 0, 1); // 3 - Letter F SubSoundStream.Write(BitConverter.GetBytes((long)0), 0, 4); // 4,5,6,7 - Length of entire file minus 8 SubSoundStream.Write(BitConverter.GetBytes('W'), 0, 1); // 8 - Letter W SubSoundStream.Write(BitConverter.GetBytes('A'), 0, 1); // 9 - Letter A SubSoundStream.Write(BitConverter.GetBytes('V'), 0, 1); // 10 - Letter V SubSoundStream.Write(BitConverter.GetBytes('E'), 0, 1); // 11 - Letter E SubSoundStream.Write(BitConverter.GetBytes('f'), 0, 1); // 12 - Letter f SubSoundStream.Write(BitConverter.GetBytes('m'), 0, 1); // 13 - Letter m SubSoundStream.Write(BitConverter.GetBytes('t'), 0, 1); // 14 - Letter t SubSoundStream.Write(BitConverter.GetBytes(' '), 0, 1); // 15 - Space SubSoundStream.Write(BitConverter.GetBytes((long)16), 0, 4); // 16,17,18,19 - Size of following subchunk SubSoundStream.Write(BitConverter.GetBytes((int)1), 0, 2); // 20,21 - Format code (PCM) SubSoundStream.Write(BitConverter.GetBytes((int)Channels), 0, 2); // 22,23 - Number of channels SubSoundStream.Write(BitConverter.GetBytes((long)Frequency), 0, 4); // 24,25,26,27 - Sampling Rate (Blocks Per Second) SubSoundStream.Write(BitConverter.GetBytes((int)DataRate), 0, 4); // 28,29,30,31 - Data rate SubSoundStream.Write(BitConverter.GetBytes(BlockAlign), 0, 2); // 32,33 - Data block size (bytes) SubSoundStream.Write(BitConverter.GetBytes(BitsPerSample), 0, 2); // 34,35 - Bits per sample SubSoundStream.Write(BitConverter.GetBytes('d'), 0, 1); // 36 - Letter d SubSoundStream.Write(BitConverter.GetBytes('a'), 0, 1); // 37 - Letter a SubSoundStream.Write(BitConverter.GetBytes('t'), 0, 1); // 38 - Letter t SubSoundStream.Write(BitConverter.GetBytes('a'), 0, 1); // 39 - Letter a SubSoundStream.Write(BitConverter.GetBytes((long)Length), 0, 4); // 40,41,42,43 - Size of Data Section return Length; }