[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

About audio effects

thank you for your hard work.
This is Matsuyama from the System Development Office.

I suddenly thought that there are audio filters, but I've only used them for reverb, so
I decided to check out other filters (effects).

Audio Filter

First, let's check what kind of filter you have.
Click here for official documentation

Low Pass Filter

Since this is a Low Pass filter, it cuts high frequencies.
This is how you hear when high frequencies are attenuated, such as on the other side of a wall or other obstruction, or behind a speaker.

High Pass Filter

This is the opposite of Low Pass, which is a filter that cuts low frequencies.
As a physical phenomenon, it should attenuate from high frequencies, so it sounds like low frequencies cannot be reproduced with cheap earphones.
It makes a clicking sound.

Echo Filter

It's an echo. It repeats the same sound attenuated.
It's like singing in a karaoke box with echo.
If you widen the spacing, it might look like Yamabiko.

Distortion Filter

Makes the sound louder regardless of volume.
Due to the low quality, the sound is distorted and sounds like cracking.

Reverb Filter

Personally, this is the filter I use the most.
It sounds like it's reverberating in a closed space, such as a hall or an underground passage.
Also, does it sound like the sound coming through a microphone?
It has the most parameters that can be set, and as an amateur, I feel like I can't make all the adjustments.

Chorus Filter

This is a filter that plays back modulated audio along with a chorus-like sound.
I tried a sample, but it didn't seem to work.
If anyone knows please let me know...

requirements

As always, we'll create an example in Unity to try it out.
① Set various filters on the Audio Listener
② Make it possible to turn each filter on/off using the checkbox
③ Specify the frequency for the Low Pass and High Pass filters with the slider
④ Make it possible to play BGM, SE, and jingle individually
⑤ Try displaying something like an audio spectrum

It's like this.
The parameters of each filter are in their default state.
All I need to do is create a UI that plays some audio.
If the audio spectrum behaves like that, it's OK.

Setting a filter on the Audio Listener

There is an Audio Listener in the Component of MainCamera, so we will add each filter below it.
All settings other than Low / High Pass Filter can be switched using checkboxes, so leave them off by default.

Allow each filter to be turned on/off with a checkbox

Created using UI.Toggle. (Like this↓)

Prepare a method for the trigger,

// Toggle for Filter public void OnClickToggleFilter(int no) { switch ((FilterNo)no) { case FilterNo.Chorus: fltChorus.enabled = tglChorus.isOn; break; case FilterNo.Distortion: fltDistortion.enabled = tglDistotion.isOn; break ; case FilterNo.Echo: fltEcho.enabled = tglEcho.isOn; break; case FilterNo.Reverv: fltReverb.enabled = tglReverv.isOn; break; } }

It's OK if you set it in OnValueChanged.

Low Pass and High Pass filters specify frequencies using sliders

Low Pass and High Pass filters can be set using sliders.
At the same time, I also create volume and pitch.

The j reflection of the slider looks like this.

① Set event listener

// Bass pass sldLoPass.onValueChanged.AddListener((value) => { setLoPass(value); });

② Set value to filter

// Low-pass filter settings private void setLoPass(float val) { var loPassHz = ExpHz(val); fltLoPass.cutoffFrequency = loPassHz; txtLoPass.text = string.Format("{0:#}", loPassHz); }

* ExpHz converts values ​​from 0.0 to 1.0 to 10 to 22000 Hz

float ExpHz(float logHz) { var t = Mathf.Log(LowHz) - Mathf.Log(HighHz); return Mathf.Exp(logHz * t) * 10f; }

Enable to play bgm, se, jingle respectively

Use UI.Button to be able to play audio.

Set up an event listener to toggle play/stop.
Use AudioSource.Play(), Stop().

// BGM play/stop btnBgmPlay.onClick.AddListener(() => { if (!bgmSource.isPlaying) bgmSource.Play(); else bgmSource.Stop(); });

Try displaying something like an audio spectrum

Finally, let's display the waveform data.
It's the one that appears in the title image.

Use GetSpectrumData() of AudioListener

I used this as a reference for implementation. (Thank you)
I want to see the spectrum analysis of sound on an actual smartphone.

Divide the audio sample obtained with GetSpectrumData() into 512 frequency bands for UI display.

AudioListener.GetSpectrumData(spectrumData, 0, FFTWindow.Hanning); var outputF = AudioSettings.outputSampleRate; // Initialize all bins for (int i=0; i <bins.Length; i++) { bins[i] = 0f; } var logMaxF = Mathf.Log(graphMaxFrequency); // 上のbinの周波数のlog var logMinF = Mathf.Log(graphMinFrequency); var logRange = logMaxF - logMinF; if (logRange <= 0f) { logRange = 8f; } // まず周波数分類 for (int i=0; i<spectrumData.Length; i++) { var f = outputF * 0.5f * (float)i / (float)spectrumData.Length; if (f == 0f) { f = float.Epsilon; } // 対数を取ってどのビンに入るか確定 float binValue = (float)bins.Length * (Mathf.Log(f) - logMinF) / logRange; int binIndex = Mathf.FloorToInt(binValue); if ((binIndex > = 0) && (binIndex < bins.Length)) { // Add data to that bin bins[binIndex] += spectrumData[i]; } }

Create a base Prefab to display in each block.
UI.Image with Width: 3, Height: 0.
Arrange these in order from the left of the screen and set the height according to the size of the value.

// Reflected on the bar for(int i=0; i

Now, when you play the audio, the waveform data will be displayed like that.

summary

I tried a bunch of audio filters.
Chorus didn't work well (tears)
I feel like it's difficult to use anything other than reverb and low pass.
Unity an Audio Mixer , so if you want to make more detailed settings, you may want to use this.
To be honest, I don't think it's a good area for amateurs to dabble in,
but that's all for today's story.

This time, I will upload it to Git.
I hope this will be of some help to you.
Unity sample

In addition, the audio data was used from the following sources.
OtoLogic Samoto
no Mori

lastly

I have opened the system development service site "SEKARAKU Lab" to which I belong.
Beyond is a one-stop service for everything from server design and construction to operation, so if you have any trouble with server-side development, please feel free to contact us.
SEKARAKU Lab: [https://sekarakulab.beyondjapan.com/](https://sekarakulab.beyondjapan.com/)

thank you.

If you found this article helpful , please give it a like!
1
Loading...
1 vote, average: 1.00 / 11
896
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Kensho Matsuyama

For a long time, he worked at a game development company, working in programs and project management.
Joined Beyond Co., Ltd. in 2019.
He works in the Yokohama office. He is mainly responsible for project management of server-side development work.
(Sometimes programming) His hobbies are cycling (road racer) and watching horse races.