letztes / achtelbass2web

achtelbass for the web
https://achtelbass.de
Other
3 stars 0 forks source link

Migrate code to python 3 #28

Closed letztes closed 5 years ago

letztes commented 6 years ago

Python 3 becomes more and more the standard python version on an increasing amount of platforms. Especially when the webhosting provider moves on to python 3 as the default version problems arise.

Please migrate the whole code to python 3. There are ways to automate this process.

https://docs.python.org/2/library/2to3.html

SmilingHorse commented 5 years ago

FYI, You could host static with some client side javascript using http://www.vexflow.com/ for rendering. Should make hosting cheaper as well. Even free.

A traditional approach could be a lilypond rewrite that would use the built-in scheme interpreter to implement the algorithm and functionality: http://lilypond.1069038.n5.nabble.com/Generating-random-notes-td157801.html That way you'd just distribute .ly file and whenever people compile it with lilypond it will produce fresh sheets.

Both solutions have their usability and technical merits. Both will free you from the hosting costs. One would have the users depend on a browser. The other would have them depend on lilypond. Practically speaking, everyone has a browser and you could even package it as an offline app for Android using something like Electron. Though from an efficiency and visual quality standpoint the winner is lilypond.

Either way, you'd be better off doing away with the python code.

letztes commented 5 years ago

Thank you for mentioning the legitimate options.

Vexflow is quite advanced in rendering visuals, however abc.js is nice at that too and additionally it can play the sound.

Anyhow your point that static hosting would suffice is still valid.

The only reason that I went for python in the first place is because I can. Because I like python and I want to keep up with it. Because I enjoy Web Development. I even built the website on django in the beginning and eventually had to move away from it in 2941089c5f1d7ec053687c5ee17fbc4e9265959a as no affordable hosting provider had django in their basic consumer packages.

That being said there is a predecessor to this web app: https://github.com/letztes/achtelbass It has a cli and a gtk+ gui and produces pretty pdf files via tex and midi files too. Comes quite close to lilypond.

SmilingHorse commented 5 years ago

Vexflow is quite advanced in rendering visuals, however abc.js is nice at that too and additionally it can play the sound.

yeah I only mentioned it because it supported tablature as well which I figures some folks would want to use for rhythm work before they learn notation.

The only reason that I went for python in the first place is because...

yeah it's as good a reason as any. And I'd probably would have done the same. But I still thought if you're looking towards a major rewrite (I'm not sure what going from 2 to 3 actually entails...), I should at least let you know about some other options out there.

That being said there is a predecessor...

Yeah I actually heard about it from https://old.reddit.com/r/NixOS/comments/al4xgf/achtelbass_generate_sheet_music_for_sight_reading/ and even patched it up a little for some more range (wanted e6 for the guitar), to use musixtex instead of pmx2pdf (deprecated) and to leave behind the output midi at the working dir (I only started reading notation and can't even trust my sense of rhythm): https://gist.github.com/SmilingHorse/33cb63db66d0c1fd5b3d6c66dd05bc8a

I even got achtelbass2web to output notes off the console again with https://gist.github.com/SmilingHorse/939220a4befdb02cc6b354fb00848cd0 but I gave up on that early since it looked like fixing the arguments input let alone the gui would be too much of a pain considering the older version works fine.

Anyhow, doing all of this got me:

  1. Thinking musixtex is a huge dependency for many that could be substituted with lilypond (1gb from livetex vs. 30mb windows binary).
  2. Figuring someone probably already done something similar which led me to the lilypond examples from before.
  3. Looking at achtelbass2web and thinking it should be doable client side with tablature which is how I found vexflow.
  4. Thinking I should at least let you know about vexflow and lilypond and ending up commenting on this issue instead opening a new one since I don't really have a personal issue so much as a few suggestions.

Regardless, like you said, the old achtelbass indeed gets the job done well enough for me so thanks!

letztes commented 5 years ago

I am glad that my efforts find real use not only for myself but for other people too.

The achtelbass -> pmx -> pdf pipeline is heavy weight indeed. And cumbersome for not so tech savvy users.

This is where achtelbass2web excels. Easily acccessible in the web browser, less dependencies to maintain.

You can run the achtelbass2web script locally and with minor modifications pipe the output to lilypond.

http://lilypond.org/doc/v2.12/Documentation/user/lilypond-program/Invoking-abc2ly#Invoking-abc2ly

Please share your results if you do so.

If I may ask, is tabulature the reason for wanting lilypond or why wouldn't you use the web app?

SmilingHorse commented 5 years ago

If I may ask, is tabulature the reason for wanting lilypond or why wouldn't you use the web app?

What I mean by tabulature is that there are guitar specific issues* that will have me cross out specific notes beyond scales, keys and modes structures that will require either:

  1. Ongoing hacks to the old code as I learn the fretboard and prepare sheets to specify certain notes and a few adhoc rules for the intervals.
  2. A whole rewrite targeting tablatures data structures directly instead / in addition to notes, scales, modes and intervals.

Anyhow, while I'm unlikely to ever commit to the latter, I figured whichever of the two I'm going to do will be done best targeting the smallest & cleanest code base with the fewest dependencies. So, a pure client-side javascript implementation came up first which will only have me learn javascript that one could just run it in the browser without having to run a server instance. Or, in case you had a reason for wanting a server-side backend like monetization, I figured I should at least advocate for lilypond instead of python3+musixtex since, looking at those samples, I figured it will end up with me only having to add a few notes here or remove a few notes there to get the results I want while using the latest code-base so if I run into bugs I could report them back.

Well, that's all assuming python 2-to-3 isn't trivial... Regardless, for my own ad-hoc hacking needs the old achtelbass is currently ok so thanks again :)

*You can get a feel for the issue here: https://www.youtube.com/watch?v=LhrGeolItvw A proper book covering the subject is Fretboard Logic by Bill Edwards.

letztes commented 5 years ago

Actually fixed in d2e78d3247de26ca0fbf105bd1289c8ce627b881