6
6
7
7
# extra lib added
8
8
import NatronGui
9
- import os , time , tempfile , posixpath
9
+ import sys , os , time , tempfile , posixpath
10
10
from os import path
11
11
12
12
def getPluginID ():
@@ -84,7 +84,7 @@ def kill_pid_player(tfKPP):
84
84
def audioToAscii (audioFileATA , asciiFileATA , dimATA , fpsATA , durationATA , xHeightATA , yHeightATA ):
85
85
# Linux & OSX
86
86
if NatronEngine .natron .isMacOSX ():
87
- exec_file = "/audio2ascii.sh"
87
+ exec_file = "/audio2ascii/audio2ascii .sh"
88
88
# complet path (.replace space need by OSX!?)
89
89
path_a2a = str (os .path .dirname (os .path .realpath (__file__ )) + exec_file ).replace (" " , "\ " ) # strage need to remove 'replace' for path configfile on MacOSX
90
90
# set input and output files
@@ -93,15 +93,15 @@ def audioToAscii(audioFileATA, asciiFileATA, dimATA, fpsATA, durationATA, xHeigh
93
93
param_a2a = str (dimATA ) + " " + str (fpsATA ) + " " + str (durationATA ) + " " + str (xHeightATA ) + " " + str (yHeightATA )
94
94
# Linux
95
95
elif NatronEngine .natron .isLinux ():
96
- exec_file = "/AudioCurve"
96
+ exec_file = "/audio2ascii/ AudioCurve"
97
97
path_a2a = str (os .path .dirname (os .path .realpath (__file__ )) + exec_file ).replace (" " , "\ " )
98
98
files_a2a = "-input \" " + str (audioFileATA )+ "\" -output \" " + str (asciiFileATA )+ "\" "
99
99
param_a2a = "-" + str (dimATA )+ " -fps " + str (fpsATA )+ " -frames " + str (durationATA )+ " -cX " + str (xHeightATA )+ " -cY " + str (yHeightATA )
100
100
# Windows
101
101
elif NatronEngine .natron .isWindows ():
102
- exec_file = "/AudioCurve.exe"
102
+ exec_file = "/audio2ascii/ AudioCurve.exe"
103
103
path_a2a = str (os .path .dirname (os .path .realpath (__file__ )) + exec_file )
104
- files_a2a = "-input '" + str (audioFileATA )+ "' -output '" + str (asciiFileATA )+ "' "
104
+ files_a2a = "-input \" " + str (audioFileATA )+ "\" -output \" " + str (asciiFileATA )+ "\" "
105
105
param_a2a = "-" + str (dimATA )+ " -fps " + str (fpsATA )+ " -frames " + str (durationATA )+ " -cX " + str (xHeightATA )+ " -cY " + str (yHeightATA )
106
106
#audio2ascii.sh exist in local plugin path ?
107
107
if os .path .exists (os .path .dirname (os .path .realpath (__file__ )) + exec_file ):
@@ -144,9 +144,8 @@ def animCurves(thisParam, fileAC, dimAC, fpsAC, durationAC ,frameStartAC):
144
144
asciiAC .close ()
145
145
146
146
def paramHasChanged (thisParam , thisNode , thisGroup , app , userEdited ):
147
-
148
147
# Read config file
149
- config_file = str (os .path .dirname (os .path .realpath (__file__ )) + "/AudioToAscii.config" ) #.replace(" ", "\ ") strange here remove for MacOSX needed line in AudioToAscii function
148
+ config_file = str (os .path .dirname (os .path .realpath (__file__ )) + "/audio2ascii/ AudioToAscii.config" ) #.replace(" ", "\ ") strange here remove for MacOSX needed line in AudioToAscii function
150
149
env_list = read_init_file (config_file )
151
150
152
151
# audio input file
@@ -246,22 +245,25 @@ def paramHasChanged(thisParam, thisNode, thisGroup, app, userEdited):
246
245
app .pane1 .Viewer1 .pause ()
247
246
app .pane1 .Viewer1 .seek (thisNode .atFrameNum .get ())
248
247
app .pane1 .Viewer1 .startForward ()
248
+ thisNode .playSync .setIconFilePath (os .path .dirname (os .path .realpath (__file__ )) + "/audio2ascii/play_enabled.png" )
249
249
else :
250
250
error_man ("Audio Editor" , "You need to set a audio file before preview !" )
251
+ thisNode .refreshUserParamsGUI ()
251
252
# Stop preview
252
253
if thisParam == thisNode .stopSync :
253
254
if tmp_file :
254
255
kill_pid_player (tmp_file )
255
256
app .pane1 .Viewer1 .pause ()
257
+ thisNode .playSync .setIconFilePath (os .path .dirname (os .path .realpath (__file__ )) + "/audio2ascii/play.png" )
256
258
else :
257
259
error_man ("Audio Editor" , "You need to set a audio file before preview !" )
258
-
260
+ thisNode . refreshUserParamsGUI ()
259
261
## / extra defs
260
262
261
263
def createInstance (app ,group ):
262
264
263
265
# Read variables in config file
264
- config_file = str (os .path .dirname (os .path .realpath (__file__ )) + "/AudioToAscii.config" ) #.replace(" ", "\ ") strange here remove for MacOSX
266
+ config_file = str (os .path .dirname (os .path .realpath (__file__ )) + "/audio2ascii/ AudioToAscii.config" ) #.replace(" ", "\ ") strange here remove for MacOSX
265
267
env_list = read_init_file (config_file )
266
268
267
269
#Create all nodes in the group
@@ -325,10 +327,8 @@ def createInstance(app,group):
325
327
lastNode .userNatron = lastNode .createPageParam ("userNatron" , "Settings" )
326
328
param = lastNode .createFileParam ("inputFile" , "Audio File" )
327
329
param .setSequenceEnabled (False )
328
-
329
330
#Add the param to the page
330
331
lastNode .userNatron .addParam (param )
331
-
332
332
#Set param properties
333
333
param .setHelp ("Path to audio file.\n Significant number of formats are supported including:\n MP3/4, WAV, W64, AIFF, OGG, FLAC." )
334
334
param .setAddNewLine (True )
@@ -337,10 +337,8 @@ def createInstance(app,group):
337
337
del param
338
338
339
339
param = lastNode .createButtonParam ("editAudio" , "Edit audio file" )
340
-
341
340
#Add the param to the page
342
341
lastNode .userNatron .addParam (param )
343
-
344
342
#Set param properties
345
343
param .setHelp ("Audio editor.\n You can setup it in 'Editor Settings" )
346
344
param .setAddNewLine (False )
@@ -351,10 +349,8 @@ def createInstance(app,group):
351
349
352
350
# Group /
353
351
param = lastNode .createGroupParam ("setEditor" , "Editor setting" )
354
-
355
352
#Add the param to the page
356
353
lastNode .userNatron .addParam (param )
357
-
358
354
#Set param properties
359
355
param .setHelp ("Unfold to setup audio editor " )
360
356
param .setAddNewLine (True )
@@ -364,10 +360,8 @@ def createInstance(app,group):
364
360
365
361
param = lastNode .createFileParam ("editApp" , "Audio editor" )
366
362
param .setSequenceEnabled (False )
367
-
368
363
#Add the param to the group, no need to add it to the page
369
364
lastNode .setEditor .addParam (param )
370
-
371
365
#Set param properties
372
366
param .setHelp ("Set the audio editor path" )
373
367
param .setAddNewLine (True )
@@ -384,10 +378,8 @@ def createInstance(app,group):
384
378
param = lastNode .createStringParam ("editParam" , "Audio editor parameters" )
385
379
param .setType (NatronEngine .StringParam .TypeEnum .eStringTypeDefault )
386
380
param .setDefaultValue ("" )
387
-
388
381
#Add the param to the group, no need to add it to the page
389
382
lastNode .setEditor .addParam (param )
390
-
391
383
#Set param properties
392
384
param .setHelp ("Set the audio editor command line parameters" )
393
385
param .setAddNewLine (False )
@@ -404,10 +396,8 @@ def createInstance(app,group):
404
396
405
397
param = lastNode .createFileParam ("curveFile" , "Curve File" )
406
398
param .setSequenceEnabled (False )
407
-
408
399
#Add the param to the page
409
400
lastNode .userNatron .addParam (param )
410
-
411
401
#Set param properties
412
402
param .setHelp ("" )
413
403
param .setAddNewLine (True )
@@ -422,10 +412,8 @@ def createInstance(app,group):
422
412
("xy" , "" )]
423
413
param .setOptions (entries )
424
414
del entries
425
-
426
415
#Add the param to the page
427
416
lastNode .userNatron .addParam (param )
428
-
429
417
#Set param properties
430
418
param .setHelp ("Curve dimensions X/Y(Left/Right)" )
431
419
param .setAddNewLine (True )
@@ -446,10 +434,8 @@ def createInstance(app,group):
446
434
param .setDisplayMinimum (0 , 0 )
447
435
param .setDisplayMaximum (100 , 0 )
448
436
param .setDefaultValue (app .frameRate .get (), 0 )
449
-
450
437
#Add the param to the page
451
438
lastNode .userNatron .addParam (param )
452
-
453
439
#Set param properties
454
440
param .setHelp ("Calculate curve with this frame rate" )
455
441
param .setAddNewLine (True )
@@ -459,10 +445,8 @@ def createInstance(app,group):
459
445
460
446
param = lastNode .createBooleanParam ("autoFR" , "Auto" )
461
447
param .setDefaultValue (1 )
462
-
463
448
#Add the param to the page
464
449
lastNode .userNatron .addParam (param )
465
-
466
450
#Set param properties
467
451
param .setHelp ("If check, set frame rate to project frame rate" )
468
452
param .setAddNewLine (False )
@@ -476,10 +460,8 @@ def createInstance(app,group):
476
460
param .setDisplayMinimum (0 , 0 )
477
461
param .setDisplayMaximum (500 , 0 )
478
462
param .setDefaultValue (240 , 0 )
479
-
480
463
#Add the param to the page
481
464
lastNode .userNatron .addParam (param )
482
-
483
465
#Set param properties
484
466
param .setHelp ("Duration of the curve in frames" )
485
467
param .setAddNewLine (True )
@@ -491,10 +473,8 @@ def createInstance(app,group):
491
473
param .setDisplayMinimum (0 , 0 )
492
474
param .setDisplayMaximum (500 , 0 )
493
475
param .setDefaultValue (100 , 0 )
494
-
495
476
#Add the param to the page
496
477
lastNode .userNatron .addParam (param )
497
-
498
478
#Set param properties
499
479
param .setHelp ("Height of X deviation in pixels" )
500
480
param .setAddNewLine (True )
@@ -506,10 +486,8 @@ def createInstance(app,group):
506
486
param .setDisplayMinimum (0 , 0 )
507
487
param .setDisplayMaximum (500 , 0 )
508
488
param .setDefaultValue (100 , 0 )
509
-
510
489
#Add the param to the page
511
490
lastNode .userNatron .addParam (param )
512
-
513
491
#Set param properties
514
492
param .setHelp ("Height of Y deviation in pixels" )
515
493
param .setAddNewLine (True )
@@ -521,10 +499,8 @@ def createInstance(app,group):
521
499
param .setDisplayMinimum (1 , 0 )
522
500
param .setDisplayMaximum (500 , 0 )
523
501
param .setDefaultValue (1 , 0 )
524
-
525
502
#Add the param to the page
526
503
lastNode .userNatron .addParam (param )
527
-
528
504
#Set param properties
529
505
param .setHelp ("Start the generate curve at this frame on the timeline" )
530
506
param .setAddNewLine (True )
@@ -533,10 +509,8 @@ def createInstance(app,group):
533
509
del param
534
510
535
511
param = lastNode .createButtonParam ("currentFrame" , "Current Frame" )
536
-
537
512
#Add the param to the page
538
513
lastNode .userNatron .addParam (param )
539
-
540
514
#Set param properties
541
515
param .setHelp ("Update start frame to current frame" )
542
516
param .setAddNewLine (False )
@@ -546,10 +520,8 @@ def createInstance(app,group):
546
520
del param
547
521
548
522
param = lastNode .createButtonParam ("importCurve" , "Generate the curve" )
549
-
550
523
#Add the param to the page
551
524
lastNode .userNatron .addParam (param )
552
-
553
525
#Set param properties
554
526
param .setHelp ("Generate curve from parameters" )
555
527
param .setAddNewLine (True )
@@ -567,10 +539,8 @@ def createInstance(app,group):
567
539
param .setMaximum (2.14748e+09 , 1 )
568
540
param .setDisplayMinimum (0 , 1 )
569
541
param .setDisplayMaximum (500 , 1 )
570
-
571
542
#Add the param to the page
572
543
lastNode .userNatron .addParam (param )
573
-
574
544
#Set param properties
575
545
param .setHelp ("Resultant Curve (keyframes)" )
576
546
param .setAddNewLine (True )
@@ -579,10 +549,8 @@ def createInstance(app,group):
579
549
del param
580
550
581
551
param = lastNode .createButtonParam ("resetCurves" , "Reset curves" )
582
-
583
552
#Add the param to the page
584
553
lastNode .userNatron .addParam (param )
585
-
586
554
#Set param properties
587
555
param .setHelp ("Reset the curves to 0" )
588
556
param .setAddNewLine (False )
@@ -591,70 +559,65 @@ def createInstance(app,group):
591
559
lastNode .resetCurves = param
592
560
del param
593
561
594
- # FFPLAY --------
595
- param = lastNode .createStringParam ("viewerAudio" , "Preview Viewer/Audio" )
596
- param .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
597
-
598
- #Add the param to the page
599
- lastNode .userNatron .addParam (param )
600
-
601
- #Set param properties
602
- param .setHelp ("" )
603
- param .setAddNewLine (True )
604
- param .setEvaluateOnChange (False )
605
- param .setAnimationEnabled (False )
606
- lastNode .viewerAudio = param
607
- del param
608
-
609
- param = lastNode .createButtonParam ("playSync" , "\u25b6 " )
610
-
611
- #Add the param to the page
612
- lastNode .userNatron .addParam (param )
613
-
614
- #Set param properties
615
- param .setHelp ("Start a preview Viewer/Audio\n For a good sync, Play/Cache the images in the viewer before start the preview" )
616
- param .setAddNewLine (True )
617
- param .setPersistant (False )
618
- param .setEvaluateOnChange (False )
619
- param .setIconFilePath (os .path .dirname (os .path .realpath (__file__ )) + "/play.png" )
620
- lastNode .playSync = param
621
- del param
622
-
623
- param = lastNode .createButtonParam ("stopSync" , "\u25a0 " )
624
-
625
- #Add the param to the page
626
- lastNode .userNatron .addParam (param )
627
-
628
- #Set param properties
629
- param .setHelp ("Stop preview Viewer/Audio" )
630
- param .setAddNewLine (False )
631
- param .setPersistant (False )
632
- param .setEvaluateOnChange (False )
633
- param .setIconFilePath (os .path .dirname (os .path .realpath (__file__ )) + "/stop.png" )
634
- lastNode .stopSync = param
635
- del param
636
-
637
- param = lastNode .createStringParam ("betterPreview" , "For a good sync, play/cache the images\n in the viewer before start the preview" )
638
- param .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
562
+ # FFPLAY -------- Since find solution for 'backgrounded' ffplay on windows !!
563
+ if not NatronEngine .natron .isWindows ():
564
+ param = lastNode .createStringParam ("viewerAudio" , "Preview Viewer/Audio" )
565
+ param .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
566
+ #Add the param to the page
567
+ lastNode .userNatron .addParam (param )
568
+ #Set param properties
569
+ param .setHelp ("" )
570
+ param .setAddNewLine (True )
571
+ param .setEvaluateOnChange (False )
572
+ param .setAnimationEnabled (False )
573
+ lastNode .viewerAudio = param
574
+ del param
639
575
640
- #Add the param to the page
641
- lastNode .userNatron .addParam (param )
642
-
643
- #Set param properties
644
- param .setHelp ("" )
645
- param .setAddNewLine (False )
646
- param .setEvaluateOnChange (False )
647
- param .setAnimationEnabled (False )
648
- lastNode .betterPreview = param
649
- del param
650
-
651
- # Create a tempfile within "ffplay pid"
652
- param = lastNode .createFileParam ("tmpFile" , "Temp File" )
653
- param .setVisible (False )
654
- tf = tempfile .NamedTemporaryFile (delete = False )
655
- param .setDefaultValue (tf .name )
656
- lastNode .tmpFile = param
657
- del param
576
+ param = lastNode .createButtonParam ("playSync" , "\u25b6 " )
577
+ #Add the param to the page
578
+ lastNode .userNatron .addParam (param )
579
+ #Set param properties
580
+ param .setHelp ("Start a preview Viewer/Audio\n For a good sync, Play/Cache the images in the viewer before start the preview" )
581
+ param .setAddNewLine (True )
582
+ param .setPersistant (False )
583
+ param .setEvaluateOnChange (False )
584
+ param .setIconFilePath (os .path .dirname (os .path .realpath (__file__ )) + "/audio2ascii/play.png" )
585
+ #param.setIconFilePath("audio2ascii/play.png") # decomment when Natron 2.0 stable is out
586
+ lastNode .playSync = param
587
+ del param
588
+
589
+ param = lastNode .createButtonParam ("stopSync" , "\u25a0 " )
590
+ #Add the param to the page
591
+ lastNode .userNatron .addParam (param )
592
+ #Set param properties
593
+ param .setHelp ("Stop preview Viewer/Audio" )
594
+ param .setAddNewLine (False )
595
+ param .setPersistant (False )
596
+ param .setEvaluateOnChange (False )
597
+ param .setIconFilePath (os .path .dirname (os .path .realpath (__file__ )) + "/audio2ascii/stop.png" )
598
+ #param.setIconFilePath("audio2ascii/stop.png") # decomment when Natron 2.0 stable is out
599
+ lastNode .stopSync = param
600
+ del param
601
+
602
+ param = lastNode .createStringParam ("betterPreview" , "For a good sync, play/cache the images\n in the viewer before start the preview" )
603
+ param .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
604
+ #Add the param to the page
605
+ lastNode .userNatron .addParam (param )
606
+ #Set param properties
607
+ param .setHelp ("" )
608
+ param .setAddNewLine (False )
609
+ param .setEvaluateOnChange (False )
610
+ param .setAnimationEnabled (False )
611
+ lastNode .betterPreview = param
612
+ del param
613
+
614
+ # Create a tempfile within "ffplay pid"
615
+ param = lastNode .createFileParam ("tmpFile" , "Temp File" )
616
+ param .setVisible (False )
617
+ tf = tempfile .NamedTemporaryFile (delete = False )
618
+ param .setDefaultValue (tf .name )
619
+ lastNode .tmpFile = param
620
+ del param
658
621
# /FFPLAY --------
659
622
660
623
# extra callback added
0 commit comments