In fact, there is no good research on the proposition of music sound effects.
Unity3d provides a wide range of structures and usage methods.
However, I have some small ideas and requirements, and the general unity information does not give me the answer.
- One is the small capacity. MP3 and Ogg can be compressed with high sound quality for more than one MB per minute, and a few more background music cannot be stored.
- One is the separation of resources from the main program to facilitate updates. Do not mention assetbundle with me. This platform is not compatible, and it is totally troublesome.
- And want an oscilloscope.
Just like this.
Problem 1: The minimum is Midi. midi is the original information of music. It is locally synthesized. It takes only one minute to increase the size of 1 Mbit/s MP3 and less than 1 Mbit/s for MIDI recording.
This problem was solved by using Midi.
However, the MIDI audio library is not small, and the check may easily contain dozens of megabytes and hundreds of megabytes.
I briefly understood the development process of Midi.
In fact, I don't know what they are talking about in the text below, just copied it.
Produced in 1981 as a device connection Standard, something like USB. It is designed specifically for music.
In 1991, a standard was formed and 128 standard instruments were developed.
The first sound card, Sound Blaster, uses FM (frequency adjustment) technology to synthesize MIDI sound.
I found out that FM technology does not need any memory.
Later, the memory was not a problem, and a wave table synthesis technology GM was developed. The tone of each instrument was recorded, and each instrument had to be recorded a lot.
The pay-as-you-go table is charged for memory usage. The windows-provided wave table is 4 MB, so it is easy to find dozens of hundreds of megabytes of data on the Internet.
MIDI can only produce musical instrument effects. For the discerning ears, you can use oggmp3 to simulate sound perfectly.
The voice Effect of FM may be a little miserable according to today's standards. However, it can provide MP3 1% capacity without any side effects.
Let's take what you need. I plan to make something 8 bit in style, and FM is enough.
The key to solving this capacity problem is to find something that can play MIDI with FM technology.
Then I found the http://forum.unity3d.com/threads/unitysynth-full-xplatform-midi-synth.130104/.
The data required for FM playback is only several hundred bytes.
It provides everything you need to play the Midi. You can use either FM or wave table technology to synthesize it.
The most important thing is that it provides an example to let me know how to use a DSP to mix unity. In this way, the last link is complete and the DSP can be used to play the synthesized sound.
Question 2: separation of resources and main programs
C # synth fully starts from sound synthesis, so it does not rely on any database, which provides a unique condition for cross-platform communication.
The solution we found has some small and elegant bugs, and I have modified it to be cross-platform. I also released a webplayer version.
Http://moshan.co/game? Id = 53, you can open it and have a look. There are dozens of built-in Midi, and the main program only has 200 K
Although the Ogg decoder is also open-source, I have not found the C # version. If you want to use Ogg for cross-platform playback, the workload may not be small.
Although WAV is not open-source, the format of Wav PCM is very simple and easy to implement. The problem is that the wav capacity is awkward. Sound effects can be used, and music cannot be used for WAV storage.
Question 3: oscilloscope
I don't understand this problem either.
I will probably know that frequency analysis uses Fourier transformation.
Then we learned how to use DSP to mix unity.
Add a DSP sound mixing, but do not change the sound. It is only used to read the sound.
Then, input the Time-Domain value of the sound obtained each time and calculate it using Fourier transform. The output of the frequency domain is obtained.
Then extract the output values according to the frequency we want to observe...
Well, in fact, I don't know what I understand in the time-domain and frequency-domain. if I talk about it in a mess, I haven't talked about Fourier transformation in recent years.
Finally, this effect was achieved.
I can do anything with this string of numbers. I just used the GUI. Button to draw some conversion sticks.
Finally, add the GitHub Source Code address.
Https://github.com/lightszero/BlockFun/tree/master/unity/MidiPlayer
Unity3d music sound effects-Midi and wave table