ekzhang / harmony

🎶 Generate four-part harmony following idiomatic voice-leading procedures with DP!
https://autoharmony.herokuapp.com
BSD 3-Clause "New" or "Revised" License
47 stars 5 forks source link

Adding alternative answers for the same progression #5

Closed napulen closed 4 years ago

napulen commented 4 years ago

This is just a proposal for voiceProgression.

As a result of DP, there may be several good answers with a low cost. In fact, several solutions with the same cost than the "best" solution chosen with min().

Instead of providing always one answer, that could be an argument numberOfAnswers that defaults to 1 (get the best progression you can find), but can be specified by the user. The solutions are sorted and then you choose the top N progressions to send back to the user.

This would be useful for generating alternative voicings of the same progression.

As I didn't want to break any backward-compatibility, I proposed the line

return ret if numberOfAnswers > 1 else ret[0]

to provide the same answer that was given before. But I made a proof of concept in generateScore, where you ask for the best 5 answers, and only keep the best one.

You know the code better to see if/how this could be actually implemented, but I hope you get the idea.

napulen commented 4 years ago

These are the top 5 answers (according to sorted) for the default B- progression:

Top 1 image

Top 2 image

Top 3 image

Top 4 image

Top 5 image

All are great, imo.

napulen commented 4 years ago

After careful consideration, I realize that maybe this feature is outside the use case of this project.

I think it's useful, for example, you could have a Generate more button that offers different versions of the same progression every time the users click on it. But maybe you prefer the simplicity of one solution.

I'll close it for now. If you think it's useful, let me know and I'll re-open it.

I think that the other PRs I made are more relevant to the project as it is now.

Cheers