tobyspark / folk-rnn-webapp

A community application for the folk-rnn folk music style modelling project
MIT License
3 stars 5 forks source link

folkrnn invalid token #124

Closed boblsturm closed 5 years ago

boblsturm commented 5 years ago

For some reason this is invalid initial abc "cB |: GC (3 C C C c2 GA"

It complains about (

tobyspark commented 5 years ago

It's a valid token, as per the generated-on-load folk_rnn_models.js.

So, hmm... will look into this tomorrow.

tobyspark commented 5 years ago

https://github.com/tobyspark/folk-rnn-webapp/blob/master/folk_rnn_site/composer/static/folk_rnn_model_utilities.js#L72

It goes wrong here. flag_indur is correctly set, but flag_innote is also set, which it shouldn't be – and its if clause comes first.

tobyspark commented 5 years ago

@boblsturm To my understanding, at line 70 (see link above) as well as flag_indur=1 there should be flag_innote=0. If you're passing a ( then you're no longer in a note, and this would fix the behaviour here.

But... I checked your original script, and it doesn't have that unsetting of innote.

?

tobyspark commented 5 years ago

Here's your script, for ease of reference.

#!/usr/bin/env python

import sys

noteset = {'a','b','c','d','e','f','g','z','x','A','B','C','D','E','F','G'}
octset = {',','\''}
accset = {'=','_','^'}
symbset = {'|','[',']',':'}
numbset = {'1','2','3','4','5','6','7','8','9'}
modset = {'/'}
contset = {'>','<'}
result = []
with sys.stdin as inputline:
  w=""
  flag_expectingnote=0
  flag_innote=0
  flag_indur=0
  for c in str(inputline.read()):
     if c in ('|','[',']'):
    if flag_innote or flag_indur:
      result.append(w)
      w=c
    else:
          w+=c
    flag_innote=0
        flag_indur=0
     elif c in ':':
    if flag_innote or flag_indur:
       result.append(w)
       w=""
       flag_innote=0
       flag_indur=0
        w+=c
     elif c in ('('):
    result.append(w)
        w=c
        flag_indur=1
     elif c in numbset:
    if flag_innote:
      result.append(w)
      w=c
      flag_indur=1
      flag_innote=0
    elif flag_indur:
          w+=c
    else:
      result.append(w)
          w=c
    flag_indur=1
     elif c in octset:
    w+=c
     elif c is '/':
    if flag_innote:
      result.append(w)
      w=c
        else:
      w+=c
    flag_indur=1
    flag_innote=0
     elif c in accset:
    if flag_innote: # terminate previous note
       result.append(w)
           w=c
        elif flag_expectingnote: # double accidental
       w+=c
    else:
      result.append(w)
          w=c
    flag_indur=0
    flag_innote=0
    flag_expectingnote=1
     elif c in noteset:
    if flag_expectingnote:
          w+=c
      flag_expectingnote=0
    else:
          if len(w)>0:
              result.append(w)
          w=c
        flag_innote=1
        flag_indur=0
     elif c in contset:
    if flag_indur:
      w+=c
    else:
          result.append(w)
          w=c
    flag_innote=0
    flag_indur=1

# append final part
result.append(w)

#print result
print ' '.join(result)
boblsturm commented 5 years ago

Yes, I agree. Seems

elif c in ('('): result.append(w) w=c flag_indur=1

should be

elif c in ('('): result.append(w) w=c flag_indur=1 flag_innote=0

On Tue, Oct 23, 2018 at 10:43 AM Toby Harris notifications@github.com wrote:

@boblsturm https://github.com/boblsturm To my understanding, at line 70 (see link above) as well as flag_indur=1 there should be flag_innote=0. If you're passing a ( then you're no longer in a note, and this would fix the behaviour here.

But... I checked your original script, and it doesn't have that unsetting of innote.

?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tobyspark/folk-rnn-webapp/issues/124#issuecomment-432154115, or mute the thread https://github.com/notifications/unsubscribe-auth/AJy6ZJ1Agkwh2_J_oe8lrufhx3WJ0xErks5untbDgaJpZM4Xxwq8 .

-- Bob L. Sturm, Associate Professor Speech, Music and Hearing School of Electronic Engineering and Computer Science Royal Institute of Technology KTH, Sweden https://highnoongmt.wordpress.com

tobyspark commented 5 years ago

Deployed.

boblsturm commented 5 years ago

Great! works.

On Tue, Oct 23, 2018 at 11:41 AM Toby Harris notifications@github.com wrote:

Deployed.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tobyspark/folk-rnn-webapp/issues/124#issuecomment-432175435, or mute the thread https://github.com/notifications/unsubscribe-auth/AJy6ZKMUkRYfwMA2r25U5BevkporItkKks5unuQ3gaJpZM4Xxwq8 .

-- Bob L. Sturm, Associate Professor Speech, Music and Hearing School of Electronic Engineering and Computer Science Royal Institute of Technology KTH, Sweden https://highnoongmt.wordpress.com