internal static unsafe SoundWave Invoke(UObject WorldContextObject, EAudioRecordingExportType ExportType, string Name, string Path, SoundSubmix SubmixToRecord, SoundWave ExistingSoundWaveToOverwrite) { long *p = stackalloc long[] { 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L }; byte *b = (byte *)p; *((IntPtr *)(b + 0)) = WorldContextObject; *(b + 8) = (byte)ExportType; var Name_handle = GCHandle.Alloc(Name, GCHandleType.Pinned); *(IntPtr *)(b + 16) = Name_handle.AddrOfPinnedObject(); *(int *)(b + IntPtr.Size + 16) = Name.Length; *(int *)(b + IntPtr.Size + 4 + 16) = Name.Length; var Path_handle = GCHandle.Alloc(Path, GCHandleType.Pinned); *(IntPtr *)(b + 32) = Path_handle.AddrOfPinnedObject(); *(int *)(b + IntPtr.Size + 32) = Path.Length; *(int *)(b + IntPtr.Size + 4 + 32) = Path.Length; *((IntPtr *)(b + 48)) = SubmixToRecord; *((IntPtr *)(b + 56)) = ExistingSoundWaveToOverwrite; Main.GetProcessEvent(AudioMixerBlueprintLibrary.DefaultObject, StopRecordingOutput_ptr, new IntPtr(p));; Name_handle.Free(); Path_handle.Free(); return(*((IntPtr *)(b + 64))); } }
void Start() { color = circle.color; waveEffect = circle.GetComponent<SoundWave>(); waveEffect.enabled = false; arrow.parent = null; }
// Update is called once per frame void Update() { if (Input.GetButtonDown("P" + playerNumber + "_Button_" + button)) { SoundWave obj = SoundWave.Create(radius, lifeTime); obj.transform.position = this.transform.position; } }
void OnSoundHit(SoundWave wave) { power += wave.getPower()*0.5f; lastHitPower+= wave.getPower(); if(lastHitPower>1)lastHitPower=1; if(power>1)power=1; lastHitDirection = wave.getDirection(transform); }
public override void UpdateComponent() { base.UpdateComponent(); if (MainPlayer.buttonDownList[whistleKey]) { SoundWave obj = SoundWave.Create(radius, lifeTime); obj.transform.position = this.transform.position; } }
internal static unsafe void Invoke(IntPtr obj, Name InName, SoundWave InWave) { long *p = stackalloc long[] { 0L, 0L, 0L, 0L }; byte *b = (byte *)p; *((Name *)(b + 0)) = InName; *((IntPtr *)(b + 16)) = InWave; Main.GetProcessEvent(obj, SetWaveParameter_ptr, new IntPtr(p));; } }
// Factory Method for SoundWave objects. Returns a instace of the SoundRing prefab with specified parameters. public static SoundWave Create(float maxRadius, float lifeTime) { if (prefab == null) { prefab = Resources.Load("Prefabs/SoundRing"); } GameObject newObject = Instantiate(prefab) as GameObject; SoundWave soundWave = newObject.GetComponent <SoundWave>(); soundWave.radius = maxRadius; soundWave.lifeTime = lifeTime; return(soundWave); }
public void OnBeginPlay() { Actor alarmSound = new Actor("AlarmSound"); AudioComponent alarmAudioComponent = new AudioComponent(alarmSound); SoundWave alarmSoundWave = SoundWave.Load("/Game/Tests/AlarmSound"); Debug.AddOnScreenMessage(-1, 5.0f, Color.PowderBlue, "Sound wave duration: " + alarmSoundWave.Duration + " seconds"); alarmSoundWave.Loop = true; alarmAudioComponent.SetSound(alarmSoundWave); alarmAudioComponent.Play(); Assert.IsTrue(alarmAudioComponent.IsPlaying); }
public static void OnBeginPlay() { Debug.Log(LogLevel.Display, "Hello, Unreal Engine!"); Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); Actor alarmSound = new Actor("AlarmSound"); AudioComponent alarmAudioComponent = new AudioComponent(alarmSound); SoundWave alarmSoundWave = SoundWave.Load("/Game/Tests/AlarmSound"); Debug.AddOnScreenMessage(-1, 5.0f, Color.PowderBlue, "Sound wave duration: " + alarmSoundWave.Duration + " seconds"); alarmSoundWave.Loop = true; alarmAudioComponent.SetSound(alarmSoundWave); alarmAudioComponent.Play(); }
private void OnCollisionEnter(Collision collision) { GameObject hittingObj = collision.gameObject; SoundWave soundWave = hittingObj.GetComponent <SoundWave>(); if (soundWave != null) { if (soundWave.waveImpactSound != null) { AudioManager.Play(soundWave.waveImpactSound, soundWave.intensity * 0.6f); } Destroy(hittingObj); UpdateAnnoyanceLevel(soundWave.intensity); } }
public void StartSoundWave() { Vector3 startPosition = transform.position; startPosition.y = startHeight; Quaternion startRotation = Quaternion.LookRotation(transform.forward); SoundWave newSoundWave = Instantiate(soundPrefab, startPosition, startRotation).GetComponent <SoundWave>(); newSoundWave.GetComponent <Rigidbody>().velocity = transform.forward * speed; newSoundWave.speed = speed; newSoundWave.intensity = intensity; AudioClip playedClip = waveReleaseSound[Random.Range(0, waveReleaseSound.Length)]; if (playedClip != null) { newSoundWave.waveImpactSound = playedClip; sourceAudioSource.clip = playedClip; sourceAudioSource.Play(); } }
public void MinMaxPitch(SoundWave wave) { float newPitch = wave.pitch; if(newPitch < wave.minPitch){ wave.minPitch = newPitch; }else if(newPitch > wave.maxPitch){ wave.maxPitch = newPitch; } }
void Start() { samples = new float[qSamples]; spectrum = new float[qSamples]; fSample = AudioSettings.outputSampleRate; square1 = new SoundWave(); square2 = new SoundWave(); triangle = new SoundWave(); noise = new SoundWave(); square1Music = gameObject.AddComponent<AudioSource>() as AudioSource; square1Music.clip = square1Clip; square2Music = gameObject.AddComponent<AudioSource>() as AudioSource; square2Music.clip = square2Clip; triangleMusic = gameObject.AddComponent<AudioSource>() as AudioSource; triangleMusic.clip = triangleClip; noiseMusic = gameObject.AddComponent<AudioSource>() as AudioSource; noiseMusic.clip = noiseClip; square1.source = gameObject.AddComponent<AudioSource>() as AudioSource; square1.source.clip = square1Clip; square1.source.mute = true; square2.source = gameObject.AddComponent<AudioSource>() as AudioSource; square2.source.clip = square2Clip; square2.source.mute = true; triangle.source = gameObject.AddComponent<AudioSource>() as AudioSource; triangle.source.clip = triangleClip; triangle.source.mute = true; noise.source = gameObject.AddComponent<AudioSource>() as AudioSource; noise.source.clip = noiseClip; noise.source.mute = true; square1Music.Play(); square2Music.Play(); triangleMusic.Play(); noiseMusic.Play(); }
void AnalyzeSound(SoundWave wave) { wave.source.GetOutputData(samples, 0); // fill array with samples int i; float sum = 0; for (i=0; i < qSamples; i++){ sum += samples[i]*samples[i]; // sum squared samples } wave.rms = Mathf.Sqrt(sum/qSamples); // rms = square root of average wave.db = 20*Mathf.Log10(rmsValue/refValue); // calculate dB if (dbValue < -160) dbValue = -160; // clamp it to -160dB min // get sound spectrum wave.source.GetSpectrumData(spectrum, 0, FFTWindow.BlackmanHarris); float maxV = 0; int maxN = 0; for (i=0; i < qSamples; i++){ // find max if (spectrum[i] > maxV && spectrum[i] > threshold){ maxV = spectrum[i]; maxN = i; // maxN is the index of max } } float freqN = maxN; // pass the index to a float variable if (maxN > 0 && maxN < qSamples-1){ // interpolate index using neighbours float dL= spectrum[maxN-1]/spectrum[maxN]; float dR= spectrum[maxN+1]/spectrum[maxN]; freqN += 0.5f*(dR*dR - dL*dL); } wave.pitch = freqN*(fSample/2)/qSamples; // convert index to frequency MinMaxPitch(wave); }
///<summary>Stop recording audio. Path can be absolute, or relative (to the /Saved/BouncedWavFiles folder). By leaving the Submix To Record field blank, you can record the master output of the game.</summary> public static SoundWave StopRecordingOutput(UObject WorldContextObject, EAudioRecordingExportType ExportType, string Name, string Path, SoundSubmix SubmixToRecord, SoundWave ExistingSoundWaveToOverwrite) => AudioMixerBlueprintLibrary_methods.StopRecordingOutput_method.Invoke(WorldContextObject, ExportType, Name, Path, SubmixToRecord, ExistingSoundWaveToOverwrite);