jjazzboss / JJazzLab

A complete and open application for automatic backing tracks generation.
https://www.jjazzlab.org
GNU Lesser General Public License v2.1
412 stars 27 forks source link

Add Import chords from text/csv #360

Closed michaelsjackson closed 1 year ago

michaelsjackson commented 1 year ago

... would be cool. Advantage would be:

Would be cool if JJazzlab would support this importing feature one day. Thanks friends.

michaelsjackson commented 1 year ago

Here is one example of output from a song of reaper forums: Estimated chords for The Reckoning - Final.mp3, which you can find here, http://forum.cockos.com/showthread.php?t=68410 :

0.000000000 N 0.046439909 C 26.284988662 Fm 27.956825396 C 30.696780045 Caug 32.415056689 C 35.015691609 Fm 35.944489795 Abaug 36.594648526 C 39.381043083 Fm 40.960000000 C 43.746394557 Fm 45.650430839 C 48.111746031 Fm 50.015782312 C 52.477097505 Fm 54.334693877 C 56.610249433 Fm 57.306848072 C7 58.653605442 C 61.718639455 C7 68.870385487 C#6 69.892063492 C7 77.601088435 C#6 78.669206349 Cm7 86.192471655 Ab6 87.585668934 C7 95.016054421 E 95.480453514 C#6 96.084172335 C7 98.406167800 Cm7 112.245260770 Fm 114.242176870 Abaug 115.449614512 C 117.818049886 Caug 120.000725623 Cm 120.883083900 C 126.688072562 Fm 128.174149659 C 131.517823129 C7 137.787210884 Cm7 140.898684807 C7 147.307392290 Bbm7 148.421950113 C7 164.722358276 C#maj7 165.558276643 Fm7 166.487074829 C 174.660498866 Fm 175.775056689 C#m 176.239455782 C 179.118730158 Fm 179.768888888 C#6 180.419047619 C 183.391201814 Caug 185.016598639 C7 187.756553287 Fm 188.546031746 C 196.487256235 Fm 196.998095238 C 200.806167800 G 205.496598639 Ab 207.865034013 Dm7 209.908390022 G 214.273741496 Ab 216.502857142 C#maj7 218.406893424 G 222.911564625 Ab 225.280000000 C#maj7 226.626757369 F 227.601995464 G 231.642267573 Ab 233.917823129 C#maj7 237.122176870 Cm 240.001451247 Fm 243.809523809 C 248.546394557 Fm7 250.450430839 C 253.097505668 Fm 256.394739229 C 257.416417233 Fm 259.181133786 Cm 261.921088435 F 262.385487528 Abmaj7 264.846802721 C 266.286439909 Fm 268.190476190 C 270.605351473 Fm 272.555827664 C 279.428934240 Fm 280.497052154 C#m 281.007891156 C 284.769523809 C#6 285.141043083 C 288.159637188 Caug 289.645714285 C7 292.524988662 Fm 294.382585034 C 296.936780045 Fm 298.469297052 C 301.255691609 Fm 301.766530612 C7 302.323809523 C#m6 302.741768707 C 309.939954648 Fm 311.426031746 C7 314.305306122 Fm 315.652063492 C 318.670657596 Fm 320.017414965 C 323.036009070 Fm 323.500408163 C 327.401360544 Fm 327.912199546 C 331.720272108 Fm 333.020589569 C 336.132063492 Fm 336.642902494 C 342.355011337 N 342.355011337 N

jjazzboss commented 1 year ago

What is the number ? Thought it would be the chord position but it seems not...

michaelsjackson commented 1 year ago

Number is time in seconds. However there are other VAMP plugins as well, which could output bar and beat numbers. Or tracking bpm tempo. From all those information, tempo in bpm, time in seconds, bar number beat number, plus the estimated chord, all could be mapped correctly to JJazzlab-X. If this is interesting for adding to JJazzlab-X, I can investigate more, how it could be done via command line using sonic-annotator. Then as output we would have a few text/csv files for the above parameters, which JJazzlab-X would need to import.

jjazzboss commented 1 year ago

If you have a file with bar/beat number on each chord name (ideally + time signature), then adding an importer in JJazzLab is quite easy. You just need to implement this interface: https://github.com/jjazzboss/JJazzLab-X/blob/master/Song/src/org/jjazz/song/spi/SongImporter.java

But problem with automatic chord recognition is that there are always errors (in your file sometimes there are 2 chords in .5 seconds!) and you spend a lot of time fixing the chords...

michaelsjackson commented 1 year ago

If there would be a CSV song import function, and I would know the required order of columns I could try to create such a CSV via the command line. Would such a CSV line be enough for example, giving one line (with bpm redundancies). bar, beat, time_signature, bpm, chord_name Above example would contain 5 columns. Which is the smallest possible beat distance for entering chords? 1 beat? Or can I also have values like 0.5 beat, or 0.1 beat for example?

Regarding errors, yes, possible, depending on the used song, but still better than nothing. For simple song types it should work quite well I guess. Quick editing for corrections I would find easier than typing all from zero yourself. Using this technique one could do many more quick experiments, mainly, choosing a song you like, then playing along with your real instrument like a guitar for example. You could take any song in the galaxy! :)

jjazzboss commented 1 year ago

To make it simple a csv file is good: bar, beat, chord_name Yes beat can be 0 or 1.25 etc. With this format I can easily make an "import chords" feature: it will just insert the chords in the current song. If a chord is "out of range" (e.g. beyond last song bar, or if the beat position does not match the time signature), I'll issue a warning.

michaelsjackson commented 1 year ago

For 4/4 time signature would not those formula calculate the correct bar and beat values, if you know the constant bpm of the song (assuming the song having constant bpm)?

time_minutes * (bpm/4) = bar
time_minutes * bpm = beat
jjazzboss commented 1 year ago

Implemented in 4.0

michaelsjackson commented 11 months ago

Happy christmas and holidays dear jjazzboss. Thanks for the new version and implementing this feature. Tested it quickly, it seems working. A few observations: 1- When using CSV as coming from sonic-annotator, e.g. Fm shown as "Fm", this will not work. Removing both " solves the situation. 2- When there is no chord in zero position an error message is shown. Holding the tiny symbol at the bottom, pulling it to time zero solves the situation. 3- Having an older linux version e.g. ubuntu 18.04 might only have an older fluidsynth package. Solution is then using the .zip package you gave hopefully. Then I can still continue with my older fluidsynth program (via qsynth for example). Just tested with one song, but it seems working. Thanks a lot my friend. Have a nice day.

jjazzboss commented 11 months ago

I've not updated doc , yet, but check out the javadoc here: https://github.com/jjazzboss/JJazzLab/blob/master/modules/Importers/src/main/java/org/jjazz/importers/api/CsvFileReader.java