AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
Hi thereThis is my first post here and I don't know if this is the best place for asking my question. Anyway I'm writing a vst like piece of software for my game inside unity and I have some problems making a smooth transition between notes. Notes mostly make a noise on creation specially when they have a low Attack duration. I wonder in a real software how engineers prevent the app from making these noises.
I recorded a graph from note amplitudes in different situations. There is a explanation on the image itself. My audio making function is an internal Unity function which can be used for post-processing on audio and in my case for generating noises. this method interval is based on project audio sample setting which currently is 44100 and is running every about 20ms.
To be clear I want to know how to blend amplitude of every notes together and diminish the unwanted speaker noises.
Code: Select all (#)
private void OnAudioFilterRead(float[] data, int channels)
{
dTime = AudioSettings.dspTime;
for (int i = 0; i < data.Length; i+= channels)
{
phase += 1 / sampling_frequency;
waveData = 0;
lock (lockObj)
{
foreach (Note note in notes)
{
bool noteFinished = false;
float sound = (float)instruments[note.track].Sound(dTime, phase, note, out noteFinished); // tracks and instruments
waveData += sound;
if (noteFinished && note.off > note.on)
note.active = false;
}
notes.RemoveAll(n => !n.active);
}
data[i] = volume * waveData;
SinField = waveData;
if (channels == 2)
{
data[i + 1] = data[i];
}
if (phase > sampling_frequency)
{
phase = 0.0;
}
}
}