63
63
import logging
64
64
import sys
65
65
66
- logging .basicConfig (stream = sys .stdout , level = logging .DEBUG )
66
+ # logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
67
67
68
68
import pygubu
69
69
import pygubu .widgets .combobox
90
90
from nbs2midi import nbs2midi
91
91
from nbsio import NBS_VERSION , VANILLA_INSTS , Instrument , Layer , NbsSong , Note
92
92
from lyric_parser import lyric2captions
93
+ from nbs2impulsetracker import nbs2it
93
94
94
95
__version__ = '1.3.0'
95
96
@@ -409,6 +410,8 @@ def on_fileTable_select(event):
409
410
2 , state = "normal" if selectionNotEmpty else "disable" )
410
411
exportMenu .entryconfig (
411
412
3 , state = "normal" if selectionNotEmpty else "disable" )
413
+ exportMenu .entryconfig (
414
+ 4 , state = "normal" if selectionNotEmpty else "disable" )
412
415
413
416
self .fileTable .bind ("<<TreeviewSelect>>" , on_fileTable_select )
414
417
@@ -735,6 +738,9 @@ def callAudioExportDialog(self):
735
738
736
739
def callJsonExportDialog (self ):
737
740
JsonExportDialog (self .toplevel , self ).run ()
741
+
742
+ def callImpulseExportDialog (self ):
743
+ ImpulseExportDialog (self .toplevel , self ).run ()
738
744
739
745
def callAboutDialog (self ):
740
746
dialogue = AboutDialog (self .toplevel , self )
@@ -1144,6 +1150,8 @@ def __init__(self, master, parent, fileExt: str, title: Optional[str], progressT
1144
1150
1145
1151
self .exportModeChanged ()
1146
1152
1153
+ self .shouldCompactNotes = True
1154
+
1147
1155
def run (self ):
1148
1156
self .d .run ()
1149
1157
@@ -1201,7 +1209,8 @@ async def work(dialog: ProgressDialog):
1201
1209
dialog .currentText .set (f"Current file: { filePath } " )
1202
1210
# Prevent data from unintended changes
1203
1211
songData : NbsSong = deepcopy (songsData [i ])
1204
- compactNotes (songData , True )
1212
+ if self .shouldCompactNotes :
1213
+ compactNotes (songData , True )
1205
1214
songData .correctData ()
1206
1215
dialog .currentProgress .set (10 ) # 10%
1207
1216
await func (songData , filePath , dialog )
@@ -1257,6 +1266,25 @@ async def nbs2json(self, data: NbsSong, filepath: str, dialog: ProgressDialog):
1257
1266
await sleep (0.001 )
1258
1267
1259
1268
1269
+ def checkFFmpeg (ps : str = '' ) -> bool :
1270
+ if not (which ('ffmpeg' ) and which ('ffprobe' )):
1271
+ instructionMsg = ''
1272
+ if os .name == 'nt' :
1273
+ instructionMsg = """
1274
+ Make sure there are ffmpeg.exe and ffprobe.exe inside the ffmpeg/bin folder.
1275
+ If not, you can download ffmpeg then put these two files in ffmpeg/bin folder."""
1276
+ elif os .name == 'posix' :
1277
+ instructionMsg = """
1278
+ Make sure the ffmpeg package is installed in the system.
1279
+ Use "sudo apt install ffmpeg" command to install ffmpeg."""
1280
+ instructionMsg = "NBSTool can't find ffmpeg, which is required to render audio." + instructionMsg
1281
+ if ps :
1282
+ instructionMsg += '\n ' + ps
1283
+ showwarning ("ffmpeg not found" , instructionMsg )
1284
+ return False
1285
+ else :
1286
+ return True
1287
+
1260
1288
class AudioExportDialog (ExportDialog ):
1261
1289
def __init__ (self , master , parent ):
1262
1290
self .formatVar : tk .StringVar
@@ -1278,18 +1306,7 @@ def __init__(self, master, parent):
1278
1306
self .stereo .set (True ) # type: ignore
1279
1307
self .includeLocked .set (True ) # type: ignore
1280
1308
1281
- if not (which ('ffmpeg' ) and which ('ffprobe' )):
1282
- instructionMsg = ''
1283
- if os .name == 'nt' :
1284
- instructionMsg = """
1285
- Make sure there are ffmpeg.exe and ffprobe.exe inside the ffmpeg/bin folder.
1286
- If not, you can download ffmpeg then put these two files in ffmpeg/bin folder."""
1287
- elif os .name == 'posix' :
1288
- instructionMsg = """
1289
- Make sure the ffmpeg package is installed in the system.
1290
- Use "sudo apt install ffmpeg" command to install ffmpeg."""
1291
- showwarning ("ffmpeg not found" ,
1292
- "NBSTool can't find ffmpeg, which is required to render audio." + instructionMsg )
1309
+ checkFFmpeg ()
1293
1310
1294
1311
def formatChanged (self , * args ):
1295
1312
self .fileExt = '.' + self .builder .get_object ('formatCombo' ).current ()
@@ -1307,6 +1324,14 @@ async def audioExport(self, data: NbsSong, filepath: str, dialog: ProgressDialog
1307
1324
ignore_missing_instruments = ignoreMissingSounds )
1308
1325
1309
1326
1327
+ class ImpulseExportDialog (ExportDialog ):
1328
+ def __init__ (self , master , parent ):
1329
+ super ().__init__ (master , parent , '.it' , "Impulse Tracker exporting" ,
1330
+ "Exporting {} files to Impulse Tracker format (.it)..." , nbs2it )
1331
+
1332
+ if not checkFFmpeg ():
1333
+ self .d .destroy ()
1334
+
1310
1335
def parseFilePaths (string : str ) -> tuple :
1311
1336
strLen = len (string )
1312
1337
ret : List [str ] = []
0 commit comments