Giter VIP home page Giter VIP logo

Comments (14)

onlaj avatar onlaj commented on May 28, 2024

I'm not sure what do you mean by that.
If you are saying that there is delay between key press and what you see on PC then there is no easy (and cheap) way to do it, there will be always some delay when using bluetooth connection.

from piano-led-visualizer.

glootkoopshire avatar glootkoopshire commented on May 28, 2024

When you record midi and audio, then try to sync it together, it doesnt line up, the midi is faster is what i meant

from piano-led-visualizer.

onlaj avatar onlaj commented on May 28, 2024

Oh right, I'm aware of that. Unfortunately this is not a problem of my script but because of external library.
I created an issue but no response yet mido/mido#205
If they will add an option to set absolute timing for midi messages I will update the script.

from piano-led-visualizer.

glootkoopshire avatar glootkoopshire commented on May 28, 2024

Would a midi splitter work for this? I have a program on my pc that records midis well

from piano-led-visualizer.

glootkoopshire avatar glootkoopshire commented on May 28, 2024

Ive found a temporary solution: it seems like after every 10 seconds in a track, the midi gets desynced by .4-.5 seconds. Idk if thereโ€™s anything you can do to fix that in your code or if its due to mido, but you can edit the midi using MidiEditor and adjust the midi every 10 secs to go forward by .4-.5 secs.

from piano-led-visualizer.

onlaj avatar onlaj commented on May 28, 2024

Nice catch. On the issue I linked I pasted the code for recording, I don't see anything that might cause the delay.
If the delay is consistent then it would be possible to write a script to fix that just after saving midi to file.

from piano-led-visualizer.

glootkoopshire avatar glootkoopshire commented on May 28, 2024

Yeah it seems like .25 second delay per 5 seconds and .50 second delay per 10, i tested it on a 2 minute long track. for perfect alignment, i think the script would have to adjust every 5 seconds for the .25 second delay. Any idea on how to do this in the code? I am not proficient in Python at all lol. If a note is played at the 5 second interval, you would move that note and the notes before the next 5 second interval forward in time by .25 seconds. If a note is hit before the 5 second interval and lasts a little bit after, you would move it up by .25 seconds + the length of the note before it hit the 5 second interval. If there is just silence at the 5 second interval, you would extend the silence by .25 seconds.

from piano-led-visualizer.

glootkoopshire avatar glootkoopshire commented on May 28, 2024

Hi, I ended up buying a midi solutions quadra thru device that works really well for recording the midi (a lil bit expensive though lol). I was working on a script to fix the delay but couldnt get it to work, i think the code is too advanced for me. The one thing i was stuck on is what is the variable that holds the time of the midi? I had all the math worked out, I just couldnt figure out how to edit the midi files time, and at a certain time.

from piano-led-visualizer.

onlaj avatar onlaj commented on May 28, 2024

This is the line in which the note is saved
saving.add_track("note_on", original_note, velocity, elapsed_time*1000)
https://github.com/onlaj/Piano-LED-Visualizer/blob/master/visualizer.py#L1255

and this is how the method works:

def add_track(self, status, note, velocity, time):
        self.track.append(Message(status, note=int(note), velocity=int(velocity), time=int(time)))

https://github.com/onlaj/Piano-LED-Visualizer/blob/master/visualizer.py#L767

I wasn't sure how to understand mido documentation but multiplying time difference between notes in seconds by 1000 seemed to work. Changing it to different values will change the time delay between the notes, but it won't fix the drift between some of them (every 5 seconds as you mentioned).

from piano-led-visualizer.

omidfk avatar omidfk commented on May 28, 2024

hi onlaj
i have same problem, what should I do?

from piano-led-visualizer.

Kadnium avatar Kadnium commented on May 28, 2024

@onlaj hi, I have this problem as well. I looked at the mido documentation and there's this line
"The time attribute is used in several different ways:
inside a track, it is delta time in ticks. This must be an integer."
And in your code it is milliseconds, is this the same as ticks? Have you tried converting the seconds to ticks using this function?

mido.second2tick(second, ticks_per_beat, tempo)
Convert absolute time in seconds to ticks.

Returns absolute time in ticks for a chosen MIDI file time resolution (ticks per beat, also called PPQN or pulses per quarter note) and tempo (microseconds per beat).

from piano-led-visualizer.

Kadnium avatar Kadnium commented on May 28, 2024

Anyone struggling with this, I have a relatively cheap solution, I bought a midi USB-USB connector that allows midi connection between two computers, it's this https://compasflamenco.com/midi-usbusb-p-4.html?language=en. I record the midi with pianoteq (any other program that records midi works) and use cantabile and loopbe to pass the midi input to the midi out and pianoteq.

from piano-led-visualizer.

onlaj avatar onlaj commented on May 28, 2024

So you can confirm it works, right?
I will add this to readme file and mention you.
The only thing I'm worried about is that this shop is always low on supply, they might run out of products quickly if I recommend it in tutorial.

from piano-led-visualizer.

Kadnium avatar Kadnium commented on May 28, 2024

Yes mine just arrived today, I tested it and works perfectly. The device has 4 inputs and 4 outputs, just make sure to select the same port (from visualizer settings) that outputs midi from your computer.
Also the connector comes with two usb cables.

from piano-led-visualizer.

Related Issues (20)

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.