1

I need to recognize notes from melody, so I used this demo code:

#! /usr/bin/env python

import sys
from aubio import source, notes

if len(sys.argv) < 2:
    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    sys.exit(1)

filename = sys.argv[1]

downsample = 1
samplerate = 44100 // downsample
if len( sys.argv ) > 2: samplerate = int(sys.argv[2])

win_s = 512 // downsample # fft size
hop_s = 256 // downsample # hop size

s = source(filename, samplerate, hop_s)
samplerate = s.samplerate

tolerance = 0.8

notes_o = notes("default", win_s, hop_s, samplerate)

print("%8s" % "time","[ start","vel","last ]")

# total number of frames read
total_frames = 0
while True:
    samples, read = s()
    new_note = notes_o(samples)
    if (new_note[0] != 0):
        note_str = ' '.join(["%.2f" % i for i in new_note])
        print("%.6f" % (total_frames/float(samplerate)), new_note)
    total_frames += read
    if read < hop_s: break

https://github.com/aubio/aubio/blob/master/python/demos/demo_notes.py

And first note in melody not determining correctly. So, i made C major musical scale and programm printed me, that the first note is Am (But it must be C). But the funniest is that the other notes are correct. My output:

    time [ start vel last ]
0.029025 [ 64. 108.  -1.]
0.516644 [ 47. 106.  64.]
0.975238 [ 49. 109.  47.]
1.439637 [ 50. 106.  49.]
1.898231 [ 52. 108.  50.]
2.362630 [ 54. 109.  52.]
2.821224 [ 56. 109.  54.]
3.285624 [ 57. 108.  56.]

First number in lists is a code for MIDI note. How could I fix it?

FlintCQ
  • 27
  • 1
  • And where is the audio .wav file? – Former contributor Nov 23 '19 at 18:34
  • https://drive.google.com/file/d/1Lz57uWPdbSS34zvZrMwNWYqZJpKISYap/view?usp=sharing – FlintCQ Nov 24 '19 at 01:36
  • ^ .wav file link – FlintCQ Nov 24 '19 at 01:37
  • 1
    The first problem with your question is that your recording corresponds to the A major scale, not C major one. First note is A2 (110 Hz, midi note 45) and last one is A3 (220 Hz, midi note 57). Another problem is the recording itself, with the sustain pedal pressed all the time, and the high harmonic richness, that doesn't help the algorithm. – Former contributor Nov 24 '19 at 13:53

0 Answers0