# Path: nord/g2/file.py
# class Prf2File(Pch2File):
#   '''Prf2File(filename) -> load a nord modular g2 performance.'''
#   def __init__(self, filename=None):
#     self.type = 'Performance'
#     self.binary_revision = 1
#     self.performance = Performance(nord.g2.modules.fromname)
#     self.performance_section = PerformanceDescription()
#     self.globalknobs_section = GlobalKnobAssignments()
#     if filename:
#       self.read(filename)
# 
#   def parse(self, memview):
#     performance = self.performance
#     performance_section = self.performance_section
#     globalknobs_section = self.globalknobs_section
#     memview = self.parse_section(performance_section, performance, memview)
#     for slot in performance.slots:
#       memview = self.parse_patch(slot.patch, memview)
#     memview = self.parse_section(globalknobs_section, performance, memview)
#     return memview
# 
#   def format_performance(self, memview):
#     performance = self.performance
#     performace_section = self.performance_section
#     globalknobs_section = self.globalknobs_section
#     memview = self.format_section(performance_section, performance, memview)
#     for slot in performance.slots:
#       memview = self.format_patch(slot.patch, memview)
#     memview = self.format_section(globalknobs_section, performance, memview)
#     return memview
# 
#   def format(self, memview):
#     return self.format_performace(memview)
# 
# Path: nord/g2/pprint.py
# def printpatch(patch):
#   printdescription(patch)
#   printvariations(patch)
#   printmodules(patch)
#   printcables(patch)
#   printknobs(patch)
#   printmidicc(patch)
#   printmorphs(patch)
# 
#   #printf('Unknown0x69:\n')
#   #printf('%s\n', '\n '.join(hexdump(patch.unknown0x69.data).split('\n')))
#   #printf('ParamNames fx:\n')
#   #printf('%s\n', '\n '.join(hexdump(patch.fx.paramnames).split('\n')))


import sys
from nord.g2.file import Prf2File
from nord.g2.pprint import printpatch
#
# This file is part of g2ools.
#
# g2ools is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# g2ools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#


def printf(fmt, *a):
  return sys.stdout.write(fmt % a)

prog = sys.argv.pop(0)
while len(sys.argv):
  filename = sys.argv.pop(0)
  printf('"%s"\n', filename)
  prf2 = Prf2File(filename)
  perf = prf2.performance
  printf(' focus: %s\n',                'abcd'[perf.description.focus])
  printf(' range enable: %s\n',         ['off','on'][perf.description.rangesel])

# Path: nord/g2/file.py
# class Prf2File(Pch2File):
#   '''Prf2File(filename) -> load a nord modular g2 performance.'''
#   def __init__(self, filename=None):
#     self.type = 'Performance'
#     self.binary_revision = 1
#     self.performance = Performance(nord.g2.modules.fromname)
#     self.performance_section = PerformanceDescription()
#     self.globalknobs_section = GlobalKnobAssignments()
#     if filename:
#       self.read(filename)
# 
#   def parse(self, memview):
#     performance = self.performance
#     performance_section = self.performance_section
#     globalknobs_section = self.globalknobs_section
#     memview = self.parse_section(performance_section, performance, memview)
#     for slot in performance.slots:
#       memview = self.parse_patch(slot.patch, memview)
#     memview = self.parse_section(globalknobs_section, performance, memview)
#     return memview
# 
#   def format_performance(self, memview):
#     performance = self.performance
#     performace_section = self.performance_section
#     globalknobs_section = self.globalknobs_section
#     memview = self.format_section(performance_section, performance, memview)
#     for slot in performance.slots:
#       memview = self.format_patch(slot.patch, memview)
#     memview = self.format_section(globalknobs_section, performance, memview)
#     return memview
# 
#   def format(self, memview):
#     return self.format_performace(memview)
# 
# Path: nord/g2/pprint.py
# def printpatch(patch):
#   printdescription(patch)
#   printvariations(patch)
#   printmodules(patch)
#   printcables(patch)
#   printknobs(patch)
#   printmidicc(patch)
#   printmorphs(patch)
# 
#   #printf('Unknown0x69:\n')
#   #printf('%s\n', '\n '.join(hexdump(patch.unknown0x69.data).split('\n')))
#   #printf('ParamNames fx:\n')
#   #printf('%s\n', '\n '.join(hexdump(patch.fx.paramnames).split('\n')))


# Path: prf2cat.py
import sys
from nord.g2.file import Prf2File
from nord.g2.pprint import printpatch

#
# This file is part of g2ools.
#
# g2ools is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# g2ools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#


def printf(fmt, *a):
  return sys.stdout.write(fmt % a)

prog = sys.argv.pop(0)
while len(sys.argv):
  filename = sys.argv.pop(0)
  printf('"%s"\n', filename)
  prf2 = Prf2File(filename)
  perf = prf2.performance
  printf(' focus: %s\n',                'abcd'[perf.description.focus])
  printf(' range enable: %s\n',         ['off','on'][perf.description.rangesel])

  printf(' master clock: %d BPM: %s\n', perf.description.bpm,