kookmin-sw / 2018-cap1-14

음원으로부터 자동으로 악보를 생성하는 프로젝트 입니다.
9 stars 2 forks source link

중간에 생기는 정크값 완화 #11

Open eddy1002 opened 6 years ago

eddy1002 commented 6 years ago

https://github.com/kookmin-sw/2018-cap1-14/blob/6d680df23de64b0660f337c8a681cc4f8519ead9/src/server/youtube_convertor/note_convertor.py#L15

def convert(self): notes = [] for i in range(0, self.block_length): part = self.wave[self.block_size i: self.block_size (i+1)] pitchs = self.__fourier_transform(part) note = [] for pitch in pitchs: note.append(self.__decide_note(pitch)) notes.append(note)

    for i in range(1, len(notes)):
        if (notes[i]["pitch"] == "_" and notes[i]["pitch"] != notes[i-1]["pitch"] and notes[i]["pitch"] != notes[i+1]["pitch"]):
            notes[i]["pitch"] = notes[i-1]["pitch"]
            notes[i]["octave"] = notes[i-1]["octave"]
    return notes