Find tunes for a few octaves of musical notes?

I am creating a Windows Phone 7 application that plays musical notes. I would like to find good .wav, .mp3 or .midi files that I can use. I looked around, but found nothing. Any suggestions on where to look?

I also looked at .NET frameworks such as NAudio and Midi.NET to find out if I can generate signals programmatically, but I could not figure out how to do this.

+4
source share
3 answers

You can create WAV files yourself using NAudio using the methods described in these articles:

and here’s a small sample program that will help you start calculating the frequency based on an octave and half tone with a 12-tone scale:

private WaveOut waveOut; private WaveRecorder waveRecorder; private void Button_Click(object sender, RoutedEventArgs e) { StartStopSineWave(); } private void StartStopSineWave() { if (waveOut == null) { int octave = 1; int note = 0; var sineWaveProvider = new SineWaveProvider32(); sineWaveProvider.SetWaveFormat(16000, 1); // 16kHz mono sineWaveProvider.Frequency = (float)(440 * Math.Pow(2, octave + note / 12.0)); sineWaveProvider.Amplitude = 0.25f; waveRecorder = new WaveRecorder(sineWaveProvider, "sample.wav"); waveOut = new WaveOut(); waveOut.Init(waveRecorder); waveOut.Play(); } else { waveOut.Stop(); waveOut.Dispose(); waveOut = null; waveRecorder.Dispose(); waveRecorder = null; } } 
+3
source

MIDI files do not contain sounds, they simply describe the sequence of notes (and other musical controls). The computer MIDI driver must take care to produce sound. If your Windows phone has a driver, you can use Midi.NET to say “play C for x seconds” and it will.

If not, you can synthesize pure tones using a simple sinusoidal function to generate waveforms. For real instruments, I don’t know any repositories - writing them well requires expensive equipment and effort, so they are rarely provided freely.

+1
source

Google for “free audio tracks” to find individually recorded instrument notes for piano, flutes, violins, drums, etc.

Soundfont is a common format for sharing free audio files intended for use in probes . As a rule, the quality of everything that you find in the public domain will vary from unsuitable to reasonable with a few remarkable exceptions of high quality.

Most soundphones will not contain separate audio files for each note. Most often, soundfonts will contain one pattern for each octave. In this case, your application will need to be able to shift note notes to the correct frequency. (This is not difficult to do and is a normal approach for samplers .)

Synthesis (generating tones programmatically) - I don’t know what your application does, but ... sine tones are simple sounds and easy to create, but it will soon become boring to hear. More interesting sounds can be created, but the sound synthesis code gets complicated quickly. I would not recommend writing your own synthesis code if it is not the main part of your application. IMHO it would be much better to use sample playback or use MIDI (if Windows Phone 7 has a good MIDI playback library).

Soundfont Archive

+1
source

Source: https://habr.com/ru/post/1334774/


All Articles