def new_notes(self, beat, notes): ns = [] for n in notes: note = self.song.Notes[n] # print note # if has_prop(note, 'Slide'): # print note.Properties.Property # print get_prop(note, 'Slide') # if has_prop(note, 'Bended'): # print note.Properties.Property # TODO slide, bend, hopo, sustain # handle fingering already there harmonic = get_prop(note, 'HarmonicType') ns.append({ '@accent': int('Accent' in note), '@bend': 0, '@fret': get_prop(note, 'Fret'), '@hammerOn': 0, '@harmonic': int(harmonic == 'Artificial'), '@harmonicPinch': int(harmonic == 'Pinch'), '@hopo': 0, '@ignore': 0, '@leftHand': -1, '@linkNext': int('Tie' in note and note.Tie['@origin']), '@mute': int(has_prop(note, 'Muted')), '@palmMute': int(has_prop(note, 'PalmMuted')), '@pickDirection': 0, '@pluck': -1, # int(has_prop(beat, 'Popped')), '@pullOff': 0, '@rightHand': -1, '@slap': -1, # int(has_prop(beat, 'Slapped')), '@slideTo': -1, '@slideUnpitchTo': -1, '@string': get_prop(note, 'String'), '@sustain': 0.0, '@tap': int(has_prop(note, 'Tapped')), '@time': self.time, '@tremolo': int('Tremolo' in beat), '@vibrato': int('Vibrato' in note), 'bendValues': [] }) if len(ns) > 1: self.chords.append(self.new_chord(beat, ns)) else: self.notes += ns
def new_chord(self, beat, notes): chordTemplate = { '@chordName': '', # TODO '@displayName': '', # TODO '@finger0': -1, '@finger1': -1, '@finger2': -1, '@finger3': -1, '@finger4': -1, '@finger5': -1, '@fret0': -1, '@fret1': -1, '@fret2': -1, '@fret3': -1, '@fret4': -1, '@fret5': -1 } for n in notes: string, fret = n['@string'], n['@fret'] chordTemplate['@fret' + str(string)] = fret find_fingering(chordTemplate) # print chordTemplate for n in notes: n['@leftHand'] = chordTemplate['@finger' + str(n['@string'])] if 'Arpeggio' in beat: chordTemplate['@displayName'] += '_arp' if not chordTemplate in self.chordTemplates: chordId = len(self.chordTemplates) self.chordTemplates.append(chordTemplate) else: chordId = self.chordTemplates.index(chordTemplate) self.handShapes.append({ '@chordId': chordId, '@endTime': self.time + self.current_beat_length * 0.90, '@startTime': self.time }) lowest_fret = [n['@fret'] for n in notes if n['@fret'] > -1] if lowest_fret != []: lowest_fret = min(lowest_fret) self.anchors.append({ '@time': self.time, '@fret': lowest_fret, '@width': 4.000 }) # TODO check any or all ? return { '@accent': int(any(n['@accent'] for n in notes)), '@chordId': chordId, '@fretHandMute': int(any(n['@mute'] for n in notes)), '@highDensity': 0, '@hopo': int(any(n['@hopo'] for n in notes)), '@ignore': int(any(n['@ignore'] for n in notes)), '@linkNext': int(any(n['@linkNext'] for n in notes)), '@palmMute': int(any(n['@palmMute'] for n in notes)), '@strum': get_prop(beat, 'Direction', 'Down').lower(), '@time': self.time, 'chordNotes': InlineContent(notes) }
def json(self): score = self.song.Score internalName = filter(str.isalnum, score.Artist) internalName += filter(str.isalnum, score.Title) part = 1 # TODO centOffset = 0 # No cent offset in GPX ? songLength = self.ebeats[-1]['@time'] if len(self.ebeats) > 0 else 0 offset = self.timefun.offset averageTempo = (len(self.ebeats) - 1) / (songLength + offset) * 60 averageTempo = int(averageTempo * 1000) / 1000.0 STANDARD_TUNING = [40, 45, 50, 55, 59, 64] tuning = get_prop(self.track, 'Tuning', STANDARD_TUNING) standardTuning = int(tuning == STANDARD_TUNING) tuning = [a - b for a, b in zip(tuning, STANDARD_TUNING)] tuning = {'@string' + str(k): tuning[k] for k in range(6)} def xany(s, prop): return int(any(n[prop] for n in s)) # TODO: check for techniques... arrangementProperties = { '@barreChords': 0, '@bassPick': 0, '@bends': xany(self.notes, '@bend'), '@bonusArr': 0, '@doubleStops': 0, '@dropDPower': 0, '@fifthsAndOctaves': 0, '@fingerPicking': 0, '@fretHandMutes': xany(self.chords, '@fretHandMute'), '@harmonics': xany(self.notes, '@harmonic'), '@hopo': xany(self.chords + self.notes, '@hopo'), '@nonStandardChords': 0, '@openChords': 0, '@palmMutes': xany(self.chords + self.notes, '@palmMute'), '@pathBass': 0, '@pathLead': 1, '@pathRhythm': 0, '@pickDirection': 0, '@pinchHarmonics': xany(self.notes, '@harmonicPinch'), '@powerChords': 0, '@represent': 1, '@slapPop': int(any(n['@slap'] != -1 or n['@pluck'] != -1 for n in self.notes)), '@slides': int(any(n['@slideTo'] != -1 for n in self.notes)), '@standardTuning': standardTuning, '@sustain': xany(self.notes, '@sustain'), '@syncopation': 0, '@tapping': xany(self.notes, '@tap'), '@tremolo': xany(self.notes, '@tremolo'), '@twoFingerPicking': 0, '@unpitchedSlides': int(any(n['@slideUnpitchTo'] != -1 for n in self.notes)), '@vibrato': xany(self.notes, '@vibrato') } return { '@version': 8, 'albumArt': internalName, 'albumName': score.Album, 'albumNameSort': text_for_sort(score.Album), 'albumYear': score.Copyright, 'arrangement': self.track.Name, 'arrangementProperties': arrangementProperties, 'artistName': score.Artist, 'artistNameSort': text_for_sort(score.Artist), 'averageTempo': averageTempo, 'capo': get_prop(self.track, 'CapoFret', 0), 'centOffset': centOffset, 'chordTemplates': self.chordTemplates, 'crowdSpeed': 1, 'ebeats': self.ebeats, 'events': self.events, 'fretHandMuteTemplates': [], 'internalName': internalName, 'lastConversionDateTime': strftime('%F %T'), 'levels': [{ '@difficulty': 0, 'anchors': self.anchors, 'chords': self.chords, 'fretHandMutes': [], 'handShapes': self.handShapes, 'notes': self.notes }], 'linkedDiffs': [], 'newLinkedDiffs': [], 'offset': offset, 'part': part, 'phraseIterations': self.phraseIterations, 'phraseProperties': [], 'phrases': self.phrases, 'sections': self.sections, 'songLength': songLength, 'songNameSort': text_for_sort(self.track.Name), 'startBeat': 0.000, 'title': score.Title, 'tone_A': '', 'tone_B': '', 'tone_C': '', 'tone_D': '', 'tone_Base': '', 'tone_Multiplayer': '', 'tones': self.tones, 'transcriptionTrack': { '@difficulty': -1, 'anchors': [], 'chords': [], 'handShapes': [], 'notes': [] }, 'tuning': tuning, 'wavefilepath': '' }