Git Product home page Git Product logo

audio-to-midi's Introduction

AUDIO TO MIDI in real time

Convert your sound into an editable music document.

Index:

Description

The idea of this project originates from an interest on music and trying to find a way to make it easier to record and edit it at the moment. Since me and my teammates enjoy both music and electronics, we decided to go this way and create this project.

The objective of this project is to make the user able to convert real sounds, whether of instruments or voice, into a MIDI format in real time. With MIDI you can put these notes into a music editor, like Reaper, and saw them the while you are playing.

This was made in team with: Joaquin Pimpignano, Iris Martinez, Juan Cruz Martinez and Violeta Martinez.

Made with:

Arduino Teensy Kicad

Software

The most important part of the project. We decide to do it on a teensy because of his memory and fast processment capacity, making posible to create a Fourier Transform for analize the signal and discover the notes in real time.

It tooks the audio and analize it with FFT and a windowing function for making it faster, it returns the dominant frequency.

float Calculate_FFT() {

  FFT = arduinoFFT(vReal, vImag, SAMPLES, SAMPLING_FREQ);
  FFT.Windowing(FFT_WIN_TYP_HAMMING, FFT_FORWARD);
  FFT.Compute(FFT_FORWARD);
  FFT.ComplexToMagnitude();

  double dominantFrequency = FFT.MajorPeak();
  return dominantFrequency;
}

Then, it looks this frequency on a defined array with the corresponding notes for each frequency range.

float NOTES_FREQ[] = { 103.826, 110.000, 116.541, 123.471, 130.813, 138.591, 146.832, 155.563, 164.814, 174.614,
                      184.997, 195.998, 207.652, 220.000, 233.082, 246.942, 261.626, 277.183, 293.665, 311.127,
                      329.628, 349.228, 369.994, 391.995, 415.305, 440.000, 466.164, 493.883, 523.251, 554.365,
                      587.330, 622.254, 659.255, 698.456, 739.989, 783.991, 830.609, 880.000, 932.328, 987.767 };
                      }

e572ef3c-88bd-41c5-94be-9d13599bbda8.jpg

#define MAX_NOTE_FREQ 987.767
#define MIN_NOTE_FREQ 103.826
#define OCTAVES_FITTING 55

float searchForNote(float freq) {

  if (freq > MAX_NOTE_FREQ || freq < MIN_NOTE_FREQ) return 0;

  for (int i = 1; i < NOTES_LENGHT - 1; i++) {

    if (freq > NOTES_FREQ[i - 1] && freq < NOTES_FREQ[i]) {
      if (freq - NOTES_FREQ[i - 1] < NOTES_FREQ[i] - freq) return i + OCTAVES_FITTING;
      else return i + OCTAVES_FITTING + 1;
    }
  }
}

Electronic filter

The project has also an electronic board who contains a circuit with:

  • Amplifier, for make the microphone signal stronger
  • Band pass filter between 100hz and 1Khz
  • Clamper circuit, for elevate the signal to the positive field

69ea6844-90a0-43a4-9217-2764cb34e035.jpg

Board designed on kicad 7.0:

Whats-App-Image-2023-08-16-at-16-10-43.jpg

Simulation:

We simulate the circuit on Proteus, here the results:

image.png

As you could see, as more amplitude on the input, the filter gets better on cutting the frequencies out of our range, but in general, it gives us a good result. On "simulation" folder you will find the proteus file for simulate it yourself.

BOM

Component Quantity
Teensy 4.0 1
Microfono Electret 1
Pot 20K ohm 1
R de 10K ohm 5
R de 100K ohm 1
R de 100 ohm 1
R de 1,5K ohm 1
R de 1M ohm 1
Cap Elec 10u 1
Cap Elec 100n 1
Cap 100n 1
Cap 1u 1
Cap 10n 1
Cap 33u 1
Lm358n 2
Lm7805 2
2N4001 1
L7806 1
ld1117 1

Colaborate

We see in this project a great potencial for implementing diferent technologies in future versions, such as an IA for better sound recognition or a dedicated software platform for colaborative musical pieces. In any case we are open to listen your ideas.

If you want to colaborate on this project, you are invited to create a Pull Request with a descriptive text of the changes/updates.

You can also contact me: [email protected]

We hope you liked the project, if so, I invite you to leave a star โญ, thanks for read :).

audio-to-midi's People

Contributors

jomarkow avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.