-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathROLLSUB.BI
6547 lines (5701 loc) · 221 KB
/
ROLLSUB.BI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
On Error Goto errorsub
'#Include "foro/window9.bi" no hace falta parece
'extern "c++"
'#include once "fltk/fl_window.bi"
'#include once "fltk/fl_button.bi"
'#include once "fltk/fl_check_button.bi"
'#include once "fltk/fl_input.bi"
'#include once "fltk/Fl_Multiline_Output.bi"
'#include once "fltk/Fl_Radio_Button.bi"
' #include once "fltk/Fl_Menu_Window.bi"
'''#include once "fltk/Fl_Table.bi" ' no funca
' '#include once "fltk/fl_Tree_Item.bi" no funca
''#include once "fltk/Fl_Table_Row.bi" ' no funca
'''#include once "fltk/Fl_Choice.bi" ' no funca
'''#Include once "fltk/fl_Input_choice.bi" '' NO FUNCA
'end extern
'''On Error GoTo errorSub
#Include Once "rollutil.bi"
Sub ArmarDurFrac ()
' los bloques de durcion se repiten de a 3, el incr es por bloque
' si voy al 2do bloque de 3 el incrdeja de ser 0 y pasa a 27 respectro de la
' 1er linea l cargo TRAck como 2da linea
Print #1,"armardurFrac procesa numeroFrac"
FileFlush (-1)
If cuart=0 And pun = 0 And doblepun=0 And tres=0 And silen=0 And mas=0 Then
numeroFrac = DUR 'era duracion
'DUR nunca se ahce cero solo para espacio ergo si pulso
' la misma u otra nota sigue con la misma duracion
EndIf
' CUART
If cuart=1 And pun = 0 And doblepun=0 And tres=0 And silen=0 And mas=0 Then
numeroFrac = DUR + 9 'era duracion
'DUR nunca se ahce cero solo para espacio ergo si pulso
' la misma u otra nota sigue con la misma duracion
EndIf
' PUNTILLO
' 3I* = I = 1 , el puntillo a un 3 suma dando la figura de la q proviene.
If cuart=0 And pun = 1 And doblepun=0 And tres=0 And silen=0 And mas=0 Then
numeroFrac = DUR + 18 'era dur
EndIf
'DOBLE PUNTILLO
If cuart=0 And pun = 0 And doblepun=1 And tres=0 And silen=0 And mas=0 Then
numeroFrac = DUR + 27
EndIf
' SEGUIR JMG
If cuart=0 And pun = 0 And doblepun=0 And tres=1 And silen=0 And mas=0 Then
numeroFrac = DUR + 36
EndIf
' -----fin 1er bloque ------------------------
If cuart=0 And pun = 0 And doblepun=0 And tres=0 And silen=1 And mas=0 Then
numeroFrac = DUR + 45 'era dur
EndIf
If cuart=1 And pun = 0 And doblepun=0 And tres=0 And silen=1 And mas=0 Then
numeroFrac = DUR + 54
EndIf
If cuart=0 And pun = 1 And doblepun=0 And tres=0 And silen=1 And mas=0 Then
numeroFrac = DUR + 63
EndIf
If cuart=0 And pun = 0 And doblepun=1 And tres=0 And silen=1 And mas=0 Then
numeroFrac = DUR + 72
EndIf
If cuart=0 And pun = 0 And doblepun=0 And tres=1 And silen=1 And mas=0 Then
numeroFrac = DUR + 81
EndIf
' -- fin 2do bloque
If cuart=0 And pun = 0 And doblepun=0 And tres=0 And silen=0 And mas=1 Then
numeroFrac = DUR + 90
EndIf
If cuart=1 And pun = 0 And doblepun=0 And tres=0 And silen=0 And mas=1 Then
numeroFrac = DUR + 99
EndIf
If cuart=0 And pun = 1 And doblepun=0 And tres=0 And silen=0 And mas=1 Then
numeroFrac = DUR + 108
EndIf
If cuart=0 And pun = 0 And doblepun=1 And tres=0 And silen=0 And mas=1 Then
numeroFrac = DUR + 117
EndIf
If cuart=0 And pun = 0 And doblepun=0 And tres=1 And silen=0 And mas=1 Then
numeroFrac = DUR + 126
EndIf
'----- fin 3er bloque
If cuart=0 And pun = 0 And doblepun=0 And tres=0 And silen=1 And mas=1 Then
numeroFrac = DUR + 135
EndIf
If cuart=1 And pun = 0 And doblepun=0 And tres=0 And silen=1 And mas=1 Then
numeroFrac = DUR + 144
EndIf
If cuart=0 And pun = 1 And doblepun=0 And tres=0 And silen=1 And mas=1 Then
numeroFrac = DUR + 153
EndIf
If cuart=0 And pun = 0 And doblepun=1 And tres=0 And silen=1 And mas=1 Then
numeroFrac = DUR + 162
EndIf
If cuart=0 And pun = 0 And doblepun=0 And tres=1 And silen=1 And mas=1 Then
numeroFrac = DUR + 171
EndIf
' ---fin 4to bloque -
cuart=0:pun=0:doblepun=0:tres=0:silen=0:mas=0
Print #1,"armardurFrac numeroFrac Resultante ", numeroFrac
FileFlush (-1)
End Sub
Sub calcCompas( ByRef j As Integer, Roll As inst)
' nota:fijarse que pasa con el grupo..1 to 4 de las 64 duraciones
' x print #1,"========================================================="
' x print #1,"1-calcCompas j o posn RECIBIDA: "; j
On Local Error GoTo errorCalc
Dim As Integer k, i,cantFalta,CantSobra, tengo, falta,sobra, noct
If DUR=0 Then ''And j >0 Then '23-03-2022 ���
compas(j).Posi=0
compas(j).nro = 0
' x print #1,"CALCOMPAS-0 DUR=0 COMPAS(J)=0 "
Exit Sub
EndIf
'If DUR=181 Then
' Compas(j).Posi=0
' Compas(j).nro = 0
' ' x print #1,"CALCOMPAS-0 DUR=181 COMPAS(J)=0 "
' Exit Sub
'EndIf
' estonunca seejecuta porque j es 4 nouncaentr con 1!!
If j= 1 Then ' 128 es el maximo de ticks de un compas se agregan amspara terminared analizar elcompas
'Erase (buffCompas_1) no usados pro ahor no son necesarios....
'Erase (buffCompas_2)
acumulado=0
''erase (compas) 'cada item es la posicion en donde
' x print #1,"J=1 comienzo calcCompas "
jc=j
EndIf
' x print #1,"1-calcCompas 2"
If jc > 128 Then
id=1
' procesar el resto que sobra luego de 129 en el buffer 2
EndIf
' ---------------------------------------------
'11-12-2021 redusco la camtidad de partes a 20
'---------------------------------------------
Dim As Integer partes_falta (1 To 20), partes_sobra(1 To 20)
' x print #1,"1-calcCompas 3, DUR: ";DUR; " j: "; j; " figura: ";figura(DUR)
For k=1 To 180
If DUR=k Then
acumulado =acumulado +pesoDur(k)
' x print #1,"acumulado / k / PEsoDur "; acumulado, k , pesoDur(k);" figura ";figura(DUR)
If Abs(d7 -acumulado) < 10 Then
acumulado = d7
EndIf
If acumulado = d7 Then
Compas(j).Posi = j
nroCompas = nroCompas+1
Compas(j).nro = nroCompas
' x print #1,"acumulado ";acumulado
' x print #1,"Compas(j) , j: ";Compas(j).Posi;" "; j
acumulado=0
jc=1
' x print #1,"1-calcCompas 3.1 exit sub acumulado=0 ";acumulado
Exit Sub
EndIf
If acumulado < d7 And j > 0 Then
' x print #1, "j que hace cancelar ";j
Compas(j).Posi = 0
Compas(j).nro = 0 ' reseteo
velocidades(j)
Print #1,"calcompas j Compas(j).nro velpos "; j , Compas(j).nro
' x print #1,"1-calcCompas 3.2 acumulado menor sigue exit sub, carga: ";carga
Exit Sub
EndIf
' cuando cargamos desde disco aca nunca es necesario pasar pues
' ya esta todo fraccionado para tener compases completos sin notas
' que sobren o falten
If carga=1 Then ' se supone que nunca carga=1 se usara en el resto
'posn=j
Exit Sub
EndIf
Dim z1 As Integer
' x print #1,"1-calcCompas acumulado 3.3 >d7 ";acumulado; " carga: ";carga
If acumulado > d7 And carga =0 Then
' x print #1,"acumulado > d7 :";acumulado
tengo= acumulado - pesoDUR(DUR)
' x print #1,"tengo "; tengo
falta=d7 - tengo
' x print #1,"falta ";falta
sobra=acumulado -d7
' x print #1,"sobra "; sobra
' Dim ultimafigura As Integer=0
separarDur(j,DUR, partes_falta(),cantFalta,falta)
' x print #1,"||||| CantFalta ";CantFalta
If CantFalta > 100 Then
' x print #1, "ERROR CANTFALTA > 100 ";CantFalta
Exit Sub
EndIf
For z1 = 1 To CantFalta
' x print #1, " ";partes_falta(z1);" ";figura(partes_falta(z1));
Next z1
' x print #1,
separarDur(j,DUR, partes_sobra(),cantSobra,sobra)
' x print #1,"||||| CantSobra ";CantSobra
If CantSobra > 100 Then
' x print #1, "ERROR CANTSOBRA > 100 ";CantSobra
Exit Sub
EndIf
For z1 = 1 To CantSobra
' x print #1, " ";partes_sobra(z1);" "; figura(partes_sobra(z1));
Next z1
' x print #1,
' x print #1,"HAGO DUR=0 BUENO.pero el sobra va a acum.."
'preparo el acumulado de Falta ntes de reemplazar
' acumulado=pesoDur(partes_sobra(CantSobra)) 'jmg 30-3-21
' ' x print #1,"acumulado sobra ";acumulado
EndIf
' x print #1,"1-calcCompas 3.4"
' EndIf
Exit For
EndIf
Next k
' x print #1,"1-calcCompas 4 ingreso a REEMPLAZO EN ROLL de las durciones y notas"
acumulado=tengo
' la ultima nota a cortar se ha cargado es la quese reemplaza de este modo
' el codigo nucleo no se toca para nada solo se copia las partes necesarias
' para imitar su comportamiento...el programa introduce auomaticamente las
' figuras de reemplazo y haria el corte ....
' valido en la carga manula pero no desde disco
' en disco esta ya todo procesado solo debo sumarduraciones
' aradeterminar compas. En Nucleo se busc siemrep la not que este en 0
' ergo parareemplazardebo borrar el contenido o reemplazarlo
If CantFalta > 0 And carga= 0 Then ' empezamos el reemplazo en el vector desde posn
' x print #1,"Recordar posn empieza en 0 "
' x print #1,"REEMPLAZO Cantfalta ";CantFalta
For k=1 To CantFalta '
If partes_falta(k)>= 1 And partes_falta(k) <=90 Then
partes_falta(k)=partes_falta(k) + 90 ' comienzan los + ligados
EndIf
' x print #1,"k,partes_falta(k), FIGURA ", k, partes_falta(k), figura(partes_falta(k))
' x print #1,"POSICION reemplazada: ";posn
Roll.trk(posn,(12-nota +(estoyEnOctava -1) * 13)).dur = partes_falta(k)
If carga=0 Then ''no hce nada en la carga
Roll.trk(posn,(12-nota +(estoyEnOctava -1) * 13)).nota = notaold
EndIf
Roll.trk(posn+1,(12-nota +(estoyEnOctava -1) * 13)).dur = 182
If notaOld > 0 And notaOld <> nota Then
Roll.trk(posn,(notaOld-1 +(estoyEnOctava -1) * 13)).dur = 181
EndIf
'------zzz
For noct = desde To hasta -1 '01-02-2022
For i= 0 To 11 ' gracias a esto anda acordes�?
If i= 12 -nota And noct = estoyEnOctava Then
Continue For
Else
If Roll.trk(posn,(i +(noct -1) * 13)).nota = 0 Then
' ' x print #1,"^^^^ cambia 0 en i";i; "octava "; noct
Roll.trk(posn,(i +(noct -1) * 13)).nota = 181
Roll.trk(posn,(i +(noct -1) * 13)).dur = 0
EndIf
EndIf
Next i
Next noct
'-------
acumulado=acumulado+pesoDur(partes_falta(k))
If Abs(d7 -acumulado) <= 10 Then
acumulado = d7
EndIf
If acumulado = d7 Then
compas(posn).Posi = posn
nroCompas=nroCompas+1
Compas(posn).nro = nroCompas
' x print #1, "Hay compas en posn ";posn
acumulado=0
posn=Posn+1
posicion = posn
MaxPos= Posicion
' x print #1,"acumulado falta: ";acumulado; " posn: ";posn
' x print #1,"d7 ";d7
Exit For
Else
compas(posn).Posi= 0
Compas(posn).nro = -2
' x print #1,"No Hay compas todavia en posn ";posn
EndIf
posn=Posn+1
posicion = posn
MaxPos= Posicion
' x print #1,"acumulado falta: ";acumulado; " posn: ";posn
' x print #1,"d7 ";d7
Next k
End If
CantFalta=0
acumulado=0 ' se supone termino el compas sino habra que forzarlo....
' x print #1,"1-calcCompas 5 carga: ";carga
If cantSobra > 0 And carga=0 Then
' x print #1,"REEMPLAZO CantSobra ";CantSobra
For k=1 To CantSobra
If k < CantSobra Then ' le agrega >, continuacion
' x print #1,"k ,partes_sobra(k),figura ";k;" ";partes_sobra(k),figura(partes_sobra(k))
' x print #1,"posicion reemplazada: ";posn
If partes_sobra(k)>= 1 And partes_sobra(k) <=90 Then
partes_sobra(k)=partes_sobra(k) + 90 ' empieza ligados +
EndIf
EndIf
Roll.trk(posn,(12-nota +(estoyEnOctava -1) * 13)).dur = partes_sobra(k)
If carga=0 Then
Roll.trk(posn,(12-nota +(estoyEnOctava -1) * 13)).nota = notaold
EndIf
Roll.trk(posn+1,(12-nota +(estoyEnOctava -1) * 13)).dur = 182
If notaOld > 0 And notaOld <> nota Then
Roll.trk(posn,(notaOld-1 +(estoyEnOctava -1) * 13)).dur = 181
EndIf
'------zzz
For noct = desde To hasta -1 ' 01-02-2022
For i= 0 To 11 ' gracias a esto anda acordes�?
If i= 12-nota And noct = estoyEnOctava Then
Continue For
Else
If Roll.trk(posn,(i +(noct -1) * 13)).nota = 0 Then
' ' x print #1,"^^^^ cambia 0 en i";i; "octava "; noct
Roll.trk(posn,(i +(noct -1) * 13)).nota = 181
Roll.trk(posn,(i +(noct -1) * 13)).dur = 0
EndIf
EndIf
Next i
Next noct
'-------
' x print #1,"ERROR==> ACUMULADO: " ;acumulado
' x print #1, "vlor buscdo de k: ";k
' x print #1,"partes_sobra(k) ";partes_sobra(k)
acumulado=acumulado + pesoDur(partes_sobra(k)) ' para el siguiente compas..�?.
' x print #1,"ERROR==> ACUMULADO: " ;acumulado
If k= CantSobra Then
CantSobra=0
Exit For
EndIf
posn=Posn+1 'jmg 30-03-21
posicion = posn
MaxPos= Posicion
Next k
' x print #1,"1-calcCompas 6"
EndIf
cantSobra=0
Erase partes_falta
Erase partes_sobra
' fin compases
' x print #1,"1-calcCompas 7 carga: ";carga
' error
Exit Sub
errorCalc:
Dim As long er1
er1 = Err()
Print #1, "er1 sos boludo o te hafces freebasic "; er1
If er1 > 0 Then
Print #1,"Error Calc detected ", er1, " posicion ";posicion; " maxpos";MaxPos;" curpos ";curpos
Print #1,"desde ";desde;" hasta ";hasta; "hasta-1 ";hasta-1; " *po ";*po
'Print #1,"*po ";*po;" semitono ";i
'Print #1,Erl, Erfn,Ermn,Err
Print #1,"---------------err calccompas---------------------"
'ErrorNumber1 = Err
'ErrorLine1 = Erl
'Dim As String ProgError1(0 To 17)
Print #1,"ERROR = ";ProgError(er1); " on line ";Erl
Print #1,"Error Function: "; *Erfn()
'ers= 11 -i +(*po) * 13
'Print #1, "11 - semitono +(*po) * 13) "; ers; "semitono ";i
'Print #1, "ubound 2 de Roll.trk ", UBound(Roll.trk, 2)
EndIf
End Sub
' ======================================================================
Sub separarDur(ByRef j As Integer, ByRef DUR As UByte,partes() As Integer, ByRef cantPArtes As Integer, ByRef falta As Integer)
On Local Error GoTo errorSepara
' S print #1,"1-Separadur "
Dim As Integer lb,lu,k,tengo,sobra, falta1,acumx
' S print #1,"EN SEPARADUR-------------------------------------------------"
lb=LBound(partes)
lu=UBound(partes)
'dim integer ultimafigura= partes(CantPartes)
falta1=falta
' S print #1,"FALTA RECIBIDO: ";FALTA1
' S print #1,;" DUR recibido: ";DUR;
Dim As Integer desder, hastar
' S print #1,"pun: ";pun;" silen: ";silen;" mas: ";mas; " tres: ";tres
' S print #1,"incr: ";incr
' cuando hago la carga los k son de 1 a 64 no son mas de 1 a 8
Select Case DUR
Case 1 To 45
incr=0
Case 46 To 90
incr=45
Case 91 To 135
incr=90
Case 136 To 180
incr=135
End Select
desder = 1 + incr
hastar = 45 + incr
For k=desder To hastar
If (falta >= pesoDur(K) - 10) And (falta <= pesoDur(K) +10) Then
partes(lb)=k
Compas(j).Posi=j ' hay compas ESTE PRODUCI DOBLES !!!! JMG SI
nroCompas = nroCompas+1
Compas(j).nro = nroCompas
' S print #1,"falta encontrado DUR ";k;" figura:";figura(k); " parte:";lb
CantPartes =lb
acumulado=0
falta=0
falta1=0
Exit Sub
Else
Compas(j).nro = 0 ' reseteo
velocidades(j)
EndIf
Next k
' si sigue es porque fall� no hay ninguna figura con esa duracion
lb=lb-1
acumx=0
' S print #1,"SEGUIMOS NO SE ENCONTRO FALTA POSN J "; J
' S print #1,"absoluto de falta1 original "; falta1
falta1=Abs(falta1)
'If falta1 >= 15000000 Then
' ' S print #1,"Caso de falla falta1 > 15000000 revisar codigo"
' Exit Sub
'Else
'CAMBIO DE ORDEN TENIA 10 A 18, 19 A 27, 28 A 36, 1 A 9
Dim CUENTA As Integer
If k<=180 And lb=0 Then ' no se encontro
Do
CUENTA += 1
For k=28+incr To 36+incr
If falta1 > pesoDur(k) Then
lb += 1
' S print #1,"dur k incr";k,incr
If lb > lu Then
Exit Do
EndIf
partes(lb)=k
' S print #1,"FALTA1 ENCONTRO PEDAZO >9a16 PArte;";lb; " figura:";figura(k); " parte:";lb
falta1=falta1-pesoDur(k)
acumx=pesoDur(k)
Exit For
End If
If (falta1 >= pesoDur(k) -10 ) And (falta1 <= pesoDur(k) + 10) Then ' si elproximo es la mitad buscodeneuvo
lb += 1
If lb > lu Then
Exit Do
EndIf
partes(lb) = k
acumx = acumx + pesoDur(k)
' S print #1,"FALTA1 ENCONTRO PEDAZO =9a16 ";lb; " figura:";figura(k); " parte:";lb
Exit For
EndIf
Next k
For k=19+incr To 27+incr
If falta1 > pesoDur(k) Then
lb += 1
' S print #1,"dur k incr";k,incr
If lb > lu Then
Exit Do
EndIf
partes(lb)=k
' S print #1,"FALTA1 ENCONTRO PEDAZO >9a16 PArte;";lb; " figura:";figura(k); " parte:";lb
falta1=falta1-pesoDur(k)
acumx=pesoDur(k)
Exit For
End If
If (falta1 >= pesoDur(k) -10 ) And (falta1 <= pesoDur(k) + 10) Then ' si elproximo es la mitad buscodeneuvo
lb += 1
If lb > lu Then
Exit Do
EndIf
partes(lb) = k
acumx = acumx + pesoDur(k)
' S print #1,"FALTA1 ENCONTRO PEDAZO =9a16 ";lb; " figura:";figura(k); " parte:";lb
Exit For
EndIf
Next k
For k=10+incr To 18+incr
If falta1 > pesoDur(k) Then
lb += 1
' S print #1,"dur k incr";k,incr
If lb > lu Then
Exit Do
EndIf
partes(lb)=k
' S print #1,"FALTA1 ENCONTRO PEDAZO >9a16 PArte;";lb; " figura:";figura(k); " parte:";lb
falta1=falta1-pesoDur(k)
acumx=pesoDur(k)
Exit For
End If
If (falta1 >= pesoDur(k) -10 ) And (falta1 <= pesoDur(k) + 10) Then ' si elproximo es la mitad buscodeneuvo
lb += 1
If lb > lu Then
Exit Do
EndIf
partes(lb) = k
acumx = acumx + pesoDur(k)
' S print #1,"FALTA1 ENCONTRO PEDAZO =9a16 ";lb; " figura:";figura(k); " parte:";lb
Exit For
EndIf
Next k
For k=1+incr To 9+incr
If falta1 > pesoDur(k) Then
lb += 1
If lb > lu Then
Exit Do
EndIf
partes(lb)=k
' S print #1,"FALTA1 ENCONTRO PEDAZO >1A8 ";lb; " figura:";figura(k); " parte:";lb
falta1=falta1-pesoDur(k)
acumx=pesoDur(k)
Exit For
End If
If (falta1 >= pesoDur(k) - 10) And (falta1 <= pesoDur(k) + 10) Then ' si elproximo es la mitad buscodeneuvo
lb += 1
If lb > lu Then
Exit Do
EndIf
partes(lb) = k
acumx = acumx + pesoDur(k)
' S print #1,"FALTA1 ENCONTRO PEDAZO = 1a8";lb;" figura:";figura(k); " parte:";lb
Exit For
EndIf
Next k
For k=37+incr To 45+incr ' tresillos
If falta1 > pesoDur(k) Then
lb += 1
' S print #1,"dur k incr";k,incr
If lb > lu Then
Exit Do
EndIf
partes(lb)=k
' S print #1,"FALTA1 ENCONTRO PEDAZO >19a27 PArte;";lb; " figura:";figura(k); " parte:";lb
falta1=falta1-pesoDur(k)
acumx=pesoDur(k)
Exit For
End If
If (falta1 >= pesoDur(k) -10 ) And (falta1 <= pesoDur(k) + 10) Then ' si elproximo es la mitad buscodeneuvo
lb += 1
If lb > lu Then
Exit Do
EndIf
partes(lb) = k
acumx = acumx + pesoDur(k)
' S print #1,"FALTA1 ENCONTRO PEDAZO =19a27 ";lb; " figura:";figura(k); " parte:";lb
Exit For
EndIf
Next k
If acumx=falta Or lb > lu Then
' S print #1,"FALTA1 FIN EN ";lb; " figura "; figura(K) ;" ACUMX";acumx
Exit Do
EndIf
If falta1 < 40000 Then
' S print #1,">> falta1 es H/2..NO DEBERIA DAR ESTO AHORA ";falta1
Exit Do
EndIf
If CUENTA = 100 Then
' S print "FALTA: ";falta;" Falta1: "; falta1
cerrar 0
Exit Do
EndIf
Loop
' S print #1,"ACUMX SEPARADUR ";acumx
EndIf
'EndIf
CantPartes =lb
' S print #1, "CANT PARTES LB, CantPartes "; LB;" "; CantPartes
' S print #1,"ACUMX ";ACUMX
'' error local
Exit Sub
errorSepara:
Dim As Integer er1, ErrorNumber1, ErrorLine1
er1 = Err
If er1 > 0 Then
Print #1,"Error Separa detected ", er1, " posicion ";posicion; " maxpos";MaxPos;" curpos ";curpos
Print #1,"desde ";desde;" hasta ";hasta; "hasta-1 ";hasta-1; " *po-1 ";*po-1;" *po+1 ";*po+1
Dim As Integer valor1, valor2
Print #1,"*po ";*po
Print #1,Erl, Erfn,Ermn,Err
Print #1,"------------------------------------"
ErrorNumber1 = Err()
ErrorLine1 = Erl
'Dim As String ProgError1(0 To 17)
Print #1,"ERROR = ";ProgError(ErrorNumber1); " on line ";ErrorLine1
Print #1,"Error Function: "; *Erfn()
'ers= 11 -semitono +(*po) * 13
Print #1, "ubound 2 de Roll.trk ", UBound(Roll.trk, 2)
EndIf
End Sub
Sub mayorDurEnUnaPosicion (ByRef posn As Integer)
Print #1,"1-MayorDurEnUnaPosicion "
Dim As Integer i, j,mayor,ia ,valdur
mayor=1
j = posn
For i= NB To NA -13
valdur => Roll.trk(j,i).dur
If valdur >= 1 And valdur <=181 Then
'print #1, "DUR mayor";DUR, mayor
If pesoDUR(valdur) > mayor Then ' las duraciones cuando mas
mayor=pesoDur(valdur)
' print #1, " DUR MAYOR";DUR,mayor
EndIf
If i=NA -13 Then
For ia=1 To 180
If mayor=pesoDur(ia) Then
valdur=ia
EndIf
Next ia
' print #1," J, valdur Mayor: "; J, valdur
DUR=valdur
calcCompas(j, Roll)
' print #1,"ABRIR compas(j) ";compas(j).Posi; " j :"; j
EndIf
EndIf
Next i
'' DUR=0
' fin compases
End Sub
'-----------
Sub ReCalCompas(Roll As inst)
On Local Error GoTo errorRecal
'If MaxPos=0 Then ' 23-03-2022 ���
' Exit Sub
'EndIf
nroCompas = 0
carga=1 ' no es lo mismo calcCompas con cargar o procesando
Dim As Integer i,j , mayor,ia,valdur,cont, semi,i2
cont=0
'print #1,"ABRIR MAXPOS ,NB,NA ";MAxPos, NB,NA
Dim As Integer tope1, tope2, grupo, mayorgrupo, noct
For j = 1 To MaxPos -2
'Print #2,"POSICION :";J
'Print #3,"POSICION :";J
cont=0
For i= NB To NA -13 ' 01-02-2022
If Roll.trk(j,i).pb = 202 Or Roll.trk(j,i).pb=201 Or Roll.trk(j,i).dur=200 Then
Continue For
EndIf
valdur => Roll.trk(j,i).dur ' de 1 a 180
' al cargr tenemos 4 grupos de 16 de duraciones identicas que se repiten
' 1-45,46-90,91-135,136-180 , el indicemeindicaa cual grupo pertenece, y
'en que rango buscar
' mayorgrupo=0
''DE LO QUE SIGUE DEBO EXTRCTAR MAYOR ENUNA POSCION Y COPIARLO
'' A ESA SUBRUTINA Y PONERLA EN NUCLEO
semi => Roll.trk(j,i).nota
If valdur > 0 And valdur < 181 And semi >=1 And semi <=12 Then
Print #1, "LECTURA DUR: ";valdur;" EN LA CARGA j: ";j;" i: "; i;" figura ";figura(valdur)
Print #3, "nota: "; i; " posi: "; j; " dur: ";valdur
' las duraciones e repiten cada 45 de modo que no importan los incr
Select Case valdur
Case 1 To 45
tope1=1:tope2=45:grupo=1:incr=0
Case 46 To 90
tope1=46:tope2=90:grupo=2:incr=45
Case 91 To 135
tope1=91:tope2=135:grupo=3:incr=90
Case 136 To 180
tope1=136:tope2=180:grupo=4:incr=135
' POR ESTO NOANDABA SILENCIOS LO LIMITE ANTES Continue For,For V19 incluimos silencios en recaocompas!!!
End Select
If valdur >= tope1 And valdur <=tope2 And tope1 > 0 And tope2> 0 Then
Print #1, "Valdur i ";valdur ; i ; " grupo ";grupo;" figura ";figura(valdur)
Print #1,"i NB ";i,NB
If cont=0 Then 'mira duraciones
mayor=pesoDur(valdur):mayorgrupo=grupo
Print #1,"1er mayor "; mayor; " mayorgrupo";mayorgrupo
cont=1
EndIf
Print #1, "DUR mayor";DUR, mayor
If pesoDUR(valdur) > mayor Then ' las duraciones cuando mas
mayor=pesoDur(valdur):mayorgrupo=grupo
Print #1,"Siguientes mayor "; mayor
Print #1, " DUR MAYOR";DUR,mayor
EndIf
Print #1,"> i= ";i; " NA= ";NA
EndIf
EndIf 'jmg OJO OJO
Dim As Integer iades =(mayorgrupo -1)*45 + 1
If mayorgrupo=0 Then '05-07-2021
iades=0
EndIf
Dim As Integer iahas = mayorgrupo * 45
If i=NA -13 Then ' 01-02-2022 vuelta atras
Print #1,"i=NA i: ";i;" NA: ";NA;" Mayor ";mayor;" grupo:"; mayorgrupo
For ia= iades To iahas ' tresillos es grupo
If mayor=pesoDur(ia) Then
valdur=ia
Print #1, "peso de mayor encontrado valdur ";valdur; "dur ";ia; " grupo ";mayorgrupo
Exit For
EndIf
Next ia
DUR=valdur
' If DUR >180 Then ' <- esto nunca se ejecuta creo se filtra antes...
' print #1,"ERROR NO SE PUEDE PASAR DUR"
' compas(j).Posi=0
' Compas(j).nro = 0
'
' Else
Dim durm As Integer
If DUR >181 Or DUR=0 Then
durm=181
Else
durm=DUR
EndIf
If DUR<=180 Then
Print #1,"ABRIR IN: J: "; J; " DUR: "; valdur;" GRUPO: "; mayorgrupo;" figura ";figura(durm)
calcCompas(j,Roll)
If carga=1 Then
'------zzz
For noct = desde To hasta
For i2= 0 To 11 ' gracias a esto anda acordes
If Roll.trk(j,(i2 +(noct -1) * 13)).nota = 0 Then
Roll.trk(j,(i2 +(noct -1) * 13)).nota = 181
Roll.trk(j,(i2 +(noct -1) * 13)).dur = 0
EndIf
Next i2
Next noct
'-------
EndIf
Print #1,"ABRIR OUT: J: "; J; " compas(j): " ;compas(j).Posi;" figura ";figura(durm)
valdur=0
DUR=0
mayor=0
EndIf
Print #3,"==============fin posicion nro: "; j
EndIf
valdur=0:DUR=0
Next i
Next j
DUR => 0
'' curpos =>0
carga=0 ' <======= control de Carga
'' error local
Exit Sub
errorRecal:
Dim As long er1
er1 = Err()
Print #1, "er1 "; er1
If er1 > 0 Then
Print #1,"Error Recal detected "; er1; " posicion ";posicion; " maxpos";MaxPos;" curpos ";curpos
Print #1,"desde ";desde;" hasta ";hasta; "hasta-1 ";hasta-1; " *po-1 ";*po-1;" *po+1 ";*po+1
'Dim As Integer valor1, valor2
'valor2= i2 +(noct -1) * 13
'Print #1,"*po ";*po;" semitono ";i2; " i2 ";valor1
'Print #1,Erl, Erfn,Ermn,Err
Print #1,"---------------err recalcompas---------------------"
'ErrorNumber1 = Err
'ErrorLine1 = Erl
' Dim As String ProgError1(0 To 17)
Print #1,"ERROR = ";ProgError(er1); " on line ";Erl
Print #1,"Error Function: "; *Erfn()
'ers= i2 +(noct -1) * 13
'Print #1, "(i2 +(noct -1) * 13) "; ers; " semitono "; i2
' Print #1, "ubound dimension 2 de Roll.trk ", UBound(Roll.trk, 2)
End If
End Sub
' ------
Sub menoryMayorEnColumna (Roll As inst, ejex As Integer, ByRef menor As UByte, ByRef mayor As UByte,ByRef i1men As Integer, ByRef i1may As Integer)
' estoy en Roll el cual es �nico tengo entonces definido las globales NB y NA por default
' recorro la columna
Print #1,"ENTRA menoryMayorEnColumna ejex NB NA "; ejex ; " " ; NB;" "; NA
If ejex = 0 Then
Print #1,"ejex es cero no se procesa"
Exit Sub
Else
Print #1,"ejex posdur "; ejex
End If
Dim As Integer i1,j1=0, DurMen,DurMay
For i1 = NB To NA -13 ' 01-02-2022
FileFlush (-1)
If Roll.trk(ejex,i1).nota >=1 And Roll.trk(ejex,i1).nota <=12 Then
If Roll.trk(ejex,i1).dur >=1 And Roll.trk(ejex,i1).dur <= 180 Then
Print #1,"=> VEO DATOS i1,nota,dur ", i1, Roll.trk(ejex,i1).nota,Roll.trk(ejex,i1).dur
j1=j1+1
If j1=1 Then
menor=Roll.trk(ejex,i1).dur
Print #1,"menor inicial ", menor
DurMen = pesoDur(menor)
Print #1,"DurMen inicial ", DurMen
mayor=Roll.trk(ejex,i1).dur
Print #1,"mayor inicial ", mayor
DurMay = pesoDur(mayor)
Print #1,"DurMay inicial ", DurMay
i1may=i1
i1men=i1
EndIf
If j1 > 1 Then
If DurMen > pesoDur(Roll.trk(ejex,i1).dur) Then
DurMen = pesoDur(Roll.trk(ejex,i1).dur)
Print #1,"DurMen sig ", DurMen
menor=Roll.trk(ejex,i1).dur
Print #1,"menor sig ", menor
i1men=i1
EndIf
If DurMay < pesoDur(Roll.trk(ejex,i1).dur) Then
DurMay = pesoDur(Roll.trk(ejex,i1).dur)
Print #1,"DurMmay sig ", DurMay
mayor=Roll.trk(ejex,i1).dur
Print #1,"mayor sig ", mayor
i1may=i1
EndIf
EndIf
EndIf
EndIf
Next i1
Print #1,"encontro menor y mayor ", menor, mayor, "En columna ",ejex
Dim As Integer notapMay, notapMen
notapMay=i1may -restar(i1may)
notapMen=i1men -restar(i1men)
Print #1,"Notapiano menor,mayor ", notapMen, notapMay
i1may=notapMay
i1men=notapMen
' ejex es fijo es al columna en analis y origen del fraccionamiento
FileFlush (-1)
End Sub
''========================= C U R S O R ============
Sub cursor(c As cairo_t Ptr,ByRef n As Integer, ByRef nro As Integer, Roll As inst)
'print #1,"1-cursor "
cairo_set_source_rgba c, 1, 1, 0.2, 1
Dim Wc As Integer
On Local Error GoTo errorhand
'Dim sobra As Integer
' sobra=MAXPOS - n -curpos
' if sobra > 0 Then
' curpos =curpos -sobra
' EndIf
'If play=1 Or playb=1 Then
wc=3*anchofig/4 '31-01-2022 23-02 tapaba la figura
'Else
' wc=inc_penta
'EndIf
'cairo_set_line_width(c, 1)
'EL CURSOR PARA UNA linea dada o nota se coloca inc_Penta mas abajo
' para B 38.5 27 notaold=1 <- actualizar please
' para C 38.5 25 notold=12
'n esla posicion al cargar datos deberia llamar a curor creo,,,probando
'curpos es la posicion relativa horizontal del cursor cuando el barrido esta
' detenido, es una foto del vector Roll inmovilizado horizontalmente, pero
' puedo navegar con cursor.,
'If s8=1 Then
' s8=0
' 'curpos=(mousex- gap1 )/35 ' 01-07-2021
' curpos=curposold
'EndIf
'curposold=curpos
If cursorVert=1 Or cursorVert= 2 Then ' vertical COMEDIT=TRUE
cairo_move_to (c, gap1 + (curpos)*anchofig, Penta_y + (notacur-1) * inc_Penta )
cairo_rectangle(c, gap1 + (curpos)*anchofig, Penta_y + (notacur-1) * inc_Penta ,wc ,inc_Penta) '13-07-2021 inc_penta/2 por inc_penta
cairo_move_to (c, gap1 + (curpos)*anchofig , Penta_y )
cairo_line_to (c, gap1 + (curpos)*anchofig , Penta_y + (notacur-1) * inc_Penta +inc_Penta )
RollDur=Roll.trk(n + curpos,12 - notacur + (*po-1) * 13 ).dur
RollNota=Roll.trk(n + curpos, 12 - notacur + (*po-1) * 13).nota
EndIf
If cursorVert= 0 And cursorHori=0 Then
If notacur=1 Then
'print #1,"notaold en cursor ";notaold
notaOld=notacur
'print #1,"notaold en cursor laigualo a 1 ";notaold
'notacur=0
EndIf
cairo_move_to (c,gap1 + (curpos)*anchofig , Penta_y + (notaOld-1) * inc_Penta )
cairo_rectangle(c,gap1 + (curpos)*anchofig, Penta_y + (notaOld-1) * inc_Penta , wc,inc_Penta)
EndIf
If cursorHori=1 Or cursorHori = 2 Then
cairo_move_to (c,gap1 + (curpos)*anchofig , Penta_y + (notaOld-1) * inc_Penta )
cairo_rectangle(c,gap1 + (curpos)*anchofig, Penta_y + (notaOld-1) * inc_Penta , wc,inc_Penta)
EndIf
If (cursorHori=1 Or cursorVert = 1) And borrar= 1 Then
' HABILITAR NOTA AL PONER EN CERO SE PUEDE USAR EN EDIT COMUN
''' If borrar= 1 Then '
cairo_set_source_rgba c, 1, 0, 0.2, 1
Dim dursaved As Integer
If notacur=1 Then ' 1 POR 0 JMG
notacur=notaOld
EndIf