-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocedures.module.txt
1801 lines (1652 loc) · 55.6 KB
/
procedures.module.txt
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
Option Compare Database
Option Explicit
Dim list As New clslist
Dim schemas As New Dictionary
Private Const ctab As Double = 0.5
Dim w As Word.Application
Dim keymap(12, 2) As Variant
Dim Notation(500, 50) As String
Dim vparas() As String
Dim paras() As String
Dim para_hi() As String
Dim para_lo() As String
Dim para_type() As String
Dim para_seq() As String
Dim gparacnt As Integer
'Dim Division As Integer 'normal division is 4 tisram is 3 this same as tempvars!nadai
'Dim tabs As Integer
'Dim beats As Single ' adi talam 8 beats
Dim tala_structure() As String 'global variable Adi talam 4,6,8
'Sub AutoOpen()
'Load_cbTalam
'End Sub
Sub load_seq(rst As Recordset)
list.newlist
With rst
Do While Not .EOF
list.append rst!Seq
rst.MoveNext
Loop
End With
list.list_nodes
End Sub
Function create_seq(pos As String, node As Long) As Long
create_seq = list.new_node(pos, node)
End Function
Sub delete_seq(node As Long)
list.Delete (node)
End Sub
Function build_schema(Lang As String) As Dictionary
Dim objtrans As Object 'transliteration class object
Dim fso As FileSystemObject
Dim folder As String
Dim lang_swaras As String
Dim rulefile As String
Dim schema As Dictionary
If Lang = "X" Then
Set build_schema = Nothing
Exit Function
End If
If Not schemas.Exists(Lang) Then
folder = get_config("LanguageFolder")
rulefile = CurrentProject.path & "\" & folder & _
"\" & Lang & ".xlsx"
Set objtrans = create_objTrans
Set schema = objtrans.schema(rulefile)
schemas.Add Lang, schema
lang_swaras = Lang & "_swaras"
rulefile = CurrentProject.path & "\" & folder & _
"\" & lang_swaras & ".xlsx"
Set schema = objtrans.schema(rulefile)
schemas.Add lang_swaras, schema
End If
Set build_schema = schemas(Lang)
End Function
Sub batch_notate()
Dim batch As Recordset
Set batch = CurrentDb.OpenRecordset( _
"select * from Kritis where status <> 'Complete' and status <> 'Error'") ' Ready or check
'
' Process records from Kriti table with status = R (ready)
Do While Not batch.EOF
notate_title (batch)
next_batch:
batch.MoveNext
Loop
End Sub
Sub notate_title(batch As Recordset)
Dim i As Long, j As Long, M As Long, n As Long, Q As Long
Dim i1 As Long, j1 As Long, m1 As Long, n1 As Long, q1 As Long
Dim Ragam As Recordset
Dim title As String
Dim fname As String, fname2 As String
Dim found As Boolean
Dim strWidth As String
Dim rec_count As Long
Dim fso As New FileSystemObject
Dim var As String
ReDim paras(200) As String
ReDim para_type(200) As String
ReDim para_seq(200) As String
setup_tempvars batch
Set w = New Word.Application
If batch!Source = "Excel" Then
rec_count = DCount("*", "Notations", "kriti = '" & batch!Kriti & "'")
If rec_count > 0 Then
batch.Edit
batch!Status = "Error"
batch!Err_msg = "Records exist in Notations table for this title"
batch.Update
Exit Sub
End If
If Not fso.FileExists(TempVars!ipath & "\" & Trim(TempVars!title) & ".xlsx") Then
batch.Edit
batch!Status = "Error"
batch!Err_msg = "Source excel File does not exist for this title"
batch.Update
Exit Sub
End If
read_xlfile batch
batch.Edit
batch!Source = "Table"
batch.Update
End If
' check batch(m+1,8) and set page orientation
'composer = batch(M, 3)
' Title line
initialise batch
' may be an option in kritis table
If batch!Source = "Table" Then
read_notations
End If
setup_abcmidi keymap
Call new_parse_xlinput
Call Create_document
out_title_lines batch
If get_config("Includelyrics") = "YES" Then
Call print_lyrics
End If
Call notate_unic
Call write_abc
If batch!Status = "Ready" Then
fname = TempVars!opath & "\" & TempVars!title & ".docx"
w.ActiveDocument.Protect Password:="notation", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
w.ActiveDocument.SaveAs2 filename:=fname, FileFormat:=wdFormatDocumentDefault
' ***Check*** code to update kritis table after the notation is generated
batch.Edit
batch!Status = "Completed"
batch.Update
' status, link to notation, lock etc
'oData.Text = "Y"
'w.ActiveDocument.Save
'
' Update Music notation list
'
End If
' End If
If batch!Status = "Check" Then
MsgBox "Check notation"
End If
w.ActiveDocument.close (False)
w.Quit
Set w = Nothing
ReDim paras(200) As String
ReDim para_type(200) As String
ReDim para_seq(200) As String
gparacnt = 0
End Sub
'
' included in code library
'
'Function get_config(p_key As String) As String
'get_config = Trim(dlookup("key_value", "Config", "key = '" & p_key & "'"))
'End Function
Sub setup_tempvars(batch As Recordset)
Dim tala_beats As String
Dim l_beats As Integer
TempVars!title = batch!Kriti & "-" & batch!Ragam & "-" & batch!Talam
TempVars!ipath = CurrentProject.path & TempVars!folder & "\" & "\" & get_config("SourceFolder")
TempVars!Filter = "kriti & '-' & ragam & '-' & talam = '" & TempVars!title & "'"
TempVars!filter_full = "user = """ & TempVars!User & """ and " & TempVars!Filter
TempVars!abcoption = UCase(get_config("abcmidioption"))
TempVars!Kriti = CStr(batch!Kriti)
TempVars!Ragam = CStr(batch!Ragam)
TempVars!Talam = CStr(batch!Talam)
TempVars!Kalai = CInt(batch!Kalai)
TempVars!tala_angam = DLookup("Angam", "Talams", "Talam='" & TempVars!Talam & "'")
TempVars!beats_per_line = CDec(batch!beats_per_line)
TempVars!Nadai = DLookup("Matra", "Nadais", "Nadai = '" & batch!Nadai & "'")
TempVars!jaathi = DLookup("Laghu", "Jathees", "Jaathi = '" & batch!Jathi & "'")
TempVars!abc_file = ""
TempVars!aro = Trim(DLookup("Arohanam", "Ragams", "Ragam='" & batch!Ragam & "'"))
TempVars!avaro = Trim(DLookup("Avarohanam", "Ragams", "Ragam='" & batch!Ragam & "'"))
TempVars!opath = CurrentProject.path & "\" & TempVars!folder & "\" & get_config("NotationFolder")
TempVars!abcpath = CurrentProject.path & "\" & TempVars!folder & "\" & get_config("abcmidifolder")
TempVars!strfilter = "kriti = '" & batch!Kriti & "' and " & _
"ragam = '" & batch!Ragam & "' and " & _
"talam = '" & batch!Talam & "'"
TempVars!Lang = CStr(Nz(batch!Lang, "X"))
set_fontnames (TempVars!Lang)
TempVars!tala_beats = build_tala_beats()
End Sub
Function build_tala_beats() As String
Dim i As Long, i_kalai As Long, i_jaathi As Long
Dim array_tala_angam() As String
Dim tala_angam As String
Dim tala_beats As String
Dim beat_count As Long
array_tala_angam = Split(TempVars!tala_angam, ",")
tala_beats = ""
beat_count = 0
For i = 0 To UBound(array_tala_angam)
For i_kalai = 1 To TempVars!Kalai
Select Case array_tala_angam(i)
Case "L"
For i_jaathi = 1 To TempVars!jaathi
beat_count = beat_count + TempVars!Nadai
tala_beats = tala_beats & beat_count & ","
Next i_jaathi
Case "A"
beat_count = beat_count + TempVars!Nadai
tala_beats = tala_beats & beat_count & ","
Case "D"
beat_count = beat_count + TempVars!Nadai
tala_beats = tala_beats & beat_count & ","
beat_count = beat_count + TempVars!Nadai
tala_beats = tala_beats & beat_count & ","
Case "C"
beat_count = beat_count + 1.5 * TempVars!Nadai
tala_beats = tala_beats & beat_count & ","
End Select
Next i_kalai
Next i
build_tala_beats = Left(tala_beats, Len(tala_beats) - 1) ' strip out the last comma
End Function
Private Sub set_fontnames(Lang As String)
If Lang = "X" Then
TempVars!Notation_font = "Segoe UI Semibold"
TempVars!Sahityam_font = "Arial Unicode Ms"
Exit Sub
End If
TempVars!Notation_font = DLookup("notation_font", "Languages", "lang = '" & Lang & "'")
TempVars!Sahityam_font = DLookup("Sahityam_font", "Languages", "lang = '" & Lang & "'")
End Sub
Private Sub out_title_lines(batch As Recordset)
Dim janya As String
Dim mela As String
Dim aro As Variant, avaro As Variant
'gparacnt = 1
'para_type(gparacnt) = "T"
'para_seq(gparacnt) = ""
write_doc "T", batch!Ragam & vbTab & batch!Kriti & vbTab & batch!Talam
'paras(gparacnt) = batch!Ragam & vbTab & batch!Kriti & vbTab & batch!Talam
'
' get the ragam details from ragam table
'
aro = Trim(DLookup("Arohanam", "Ragams", "Ragam='" & batch!Ragam & "'"))
avaro = Trim(DLookup("Avarohanam", "Ragams", "Ragam='" & batch!Ragam & "'"))
mela = Trim(DLookup("Mela", "Ragams", "Ragam='" & batch!Ragam & "'"))
janya = Trim(DLookup("Classification", "Ragams", "Ragam='" & batch!Ragam & "'"))
' moorchana
mela = "Mela " & mela & " " & janya
'gparacnt = gparacnt + 1
'para_type(gparacnt) = "M"
'para_seq(gparacnt) = ""
write_doc "M", "Aro:" & vbTab & aro & vbTab & mela & vbTab & batch!Composer
'paras(gparacnt) = "Aro:" & vbTab & aro & vbTab & mela & vbTab & batch!Composer
'vparas(gparacnt) = "M" & "$" & "" & "$" & _
' "Aro:" & vbTab & aro & vbTab & mela & vbTab & batch(M, 3)
'gparacnt = gparacnt + 1
'para_type(gparacnt) = "M"
'para_seq(gparacnt) = ""
write_doc "M", "Avaro:" & vbTab & avaro
'paras(gparacnt) = "Avaro:" & vbTab & avaro
End Sub
Function search_array(arr As Variant, column As Long, what As Variant, found As Boolean) As Long
Dim M As Long
found = False
search_array = 0
For M = LBound(arr, 1) To UBound(arr, 1)
If arr(M, column) = what Then
search_array = M
found = True
Exit For
End If
Next M
End Function
Sub read_xlfile(rst As Recordset)
Dim ifile As String
Dim title As String
Dim Notes As Recordset
Dim lngseq As Long, lng_line As Long
Dim flush As Boolean
Dim strtext As String
Dim strheading As String
Dim vstr As String
Dim lng_seq As Long
Dim rng As Excel.Range
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim rw As Excel.Range
Dim i As Long
'ReDim Preserve paras(200) As String
'ReDim Preserve para_type(200) As String
'ReDim Preserve para_seq(200) As String
'ReDim para_hi(200) As String
'ReDim para_lo(200) As String
Set Notes = CurrentDb.OpenRecordset("Notations")
Set xlApp = CreateObject("Excel.Application")
'title = rst!Kriti & "-" & rst!Ragam & "-" & rst!Talam
ifile = TempVars!ipath & "\" & Trim(TempVars!title) & ".xlsx"
xlApp.Workbooks.Open filename:=ifile
Set xlSheet = xlApp.ActiveSheet
Set rng = xlSheet.UsedRange
'gparacnt = 0
For Each rw In rng.Rows
If IsEmpty(rw.Cells(1, 1)) Then GoTo next_row
If UCase(rw.Cells(1, 1).Value) = "H" Then
' If flush Then
' notes.Update
' flush = False
' End If
strheading = rw.Cells(1, 3).Value
End If
If UCase(rw.Cells(1, 1).Value) = "N" Or UCase(rw.Cells(1, 1).Value) = "+" Then
' If flush Then
' notes.Update
' flush = False
' End If
Notes.AddNew
Notes!User = rst!User
Notes!Kriti = rst!Kriti
Notes!Ragam = rst!Ragam
Notes!Talam = rst!Talam
Notes!Heading = Trim(clean(strheading))
strtext = ""
lng_seq = lng_seq + 16
Notes!Seq = lng_seq
If Len(clean(rw.Cells(1, 2).Value2)) = 0 Then
Notes!Sangathi = vbNull
Else
Notes!Sangathi = clean(rw.Cells(1, 2).Value2)
'Else
' Notes!Sangathi = vbNull
End If
For i = 3 To rw.Columns.Count
If rw.Cells(1, i) <> "" And rw.Cells(1, i) <> "|" Then
strtext = strtext & rw.Cells(1, i).Value
End If
Next i
strtext = Replace(strtext, "/", "'")
strtext = Replace(strtext, "\", ".")
Notes!Swaram = strtext
End If
If UCase(rw.Cells(1, 1).Value) = "S" Then 'Sahithyam
' flush = True
strtext = ""
For i = 3 To rw.Columns.Count
vstr = Trim(rw.Cells(1, i).Value)
If vstr = "" Then GoTo next_i
If Right(vstr, 1) = "-" Then
vstr = Left(vstr, Len(vstr) - 1)
End If
If vstr <> "" And vstr <> "|" Then
strtext = strtext & vstr
If get_config("readxlfilecomma") = "YES" And vstr <> ";" And vstr <> "," Then
strtext = strtext & ","
End If
End If
next_i:
Next i
Notes!Sahithyam = strtext
Notes.Update
End If
' gparacnt = gparacnt + 1
' para_type(gparacnt) = UCase(rw.Cells(1, 1).Value)
' para_seq(gparacnt) = rw.Cells(1, 2).Value
'
' For i = 3 To rw.Columns.Count
' If rw.Cells(1, i) <> "" Then
' paras(gparacnt) = paras(gparacnt) & rw.Cells(1, i).Value
' End If
' Next i
next_row:
Next rw
'read the sheet and build the array straight
xlApp.ActiveWorkbook.close
xlApp.Quit
Set xlSheet = Nothing
End Sub
Private Sub read_notations()
Dim rst As Recordset
Dim strheading As String
Set rst = CurrentDb.OpenRecordset("select * from Notations where " & TempVars!strfilter & _
" order by kriti, ragam, talam, seq ")
strheading = Space(1)
Do While Not rst.EOF
If rst!Heading <> strheading Then
strheading = rst!Heading
gparacnt = gparacnt + 1
para_type(gparacnt) = "H"
'para_seq(gparacnt) = rw.Cells(1, 2).Value
paras(gparacnt) = strheading
End If
gparacnt = gparacnt + 1
para_type(gparacnt) = "N"
para_seq(gparacnt) = Nz(rst!Sangathi, " ")
paras(gparacnt) = rst!Swaram
gparacnt = gparacnt + 1
para_type(gparacnt) = "S"
paras(gparacnt) = rst!Sahithyam
rst.MoveNext
Loop
End Sub
Sub initialise(batch As Recordset)
Dim beats As Single
Dim i As Long, talaidx As Long, jaathiidx As Long
Dim tala_array() As Variant
Dim jaathi_array() As Variant
Dim found As Boolean
Dim Talam As String
Dim array_tala_angam() As String
Dim tala_angam As String
'get the path from configuration o
'Get the transliteration schema
build_schema (TempVars!Lang) ' version 5
tala_angam = DLookup("Angam", "Talams", "Talam='" & TempVars!Talam & "'")
beats = 0
array_tala_angam = Split(tala_angam, ",")
Talam = ""
For i = 0 To UBound(array_tala_angam)
Select Case array_tala_angam(i)
Case "L"
beats = beats + TempVars!jaathi * batch!Kalai
Case "A"
beats = beats + 1 * batch!Kalai
Case "D"
beats = beats + 2 * batch!Kalai
Case "C"
beats = beats + 1.5 * batch!Kalai
End Select
Talam = Talam & beats & ","
Next i
Talam = Left(Talam, Len(Talam) - 1)
tala_structure = Split(Talam, ",")
'Division = TempVars!Nadai
TempVars.Add "div_per_line", TempVars!Nadai * TempVars!beats_per_line 'adi 4 * 4 = 16
TempVars.Add "tala_cycle", beats * TempVars!Nadai
'Set odoc = ActiveDocument
'w.Selection.Font.Size = 12
End Sub
Sub new_parse_xlinput()
'declarations
Dim mcnt As Variant
Dim vseq As Long
Dim str_array() As String
Dim colon_pos As Long
Dim vstr As String, wstr As String, c As String, nextc As String
Dim strlen As Integer
Dim split_hash() As String
Dim split_notation() As String
Dim split_sahityam() As String
Dim matra As Single, matracnt As Single
Dim i As Integer, j As Integer, k As Integer
Dim regex1 As New RegExp
Dim regex2 As New RegExp
Dim regexlc As New RegExp
Dim regex As New RegExp
Dim matra_div As Integer
Dim berror As Boolean
'
'new idea to build the notation in array
'only for sahityam
'
ReDim Preserve paras(gparacnt)
ReDim Preserve para_hi(gparacnt)
ReDim Preserve para_lo(gparacnt)
ReDim Preserve para_type(gparacnt)
ReDim Preserve para_seq(gparacnt)
'ReDim duritha(gparacnt)
For i = 1 To UBound(paras)
'
If para_type(i) Like "[!S,N]" Or paras(i) = "" Then GoTo next_i
'
vstr = paras(i)
mcnt = Count_aksharams(vstr, TempVars!title, para_type(i), "$", berror)
'Debug.Print mcnt
wstr = ""
vstr = Replace(vstr, "-", "")
If Len(vstr) > 1 Then
vstr = Left(vstr, Len(vstr) - 1)
paras(i) = vstr
End If
next_i:
Next i
' check matra count
j = 0
For i = 1 To UBound(paras)
If para_type(i) = "T" Or para_type(i) = "M" Then
j = j + 1
End If
If para_type(i) = "S" Or para_type(i) = "N" Then
'Call check_matra_count(i - j, paras(i))
End If
Next i
End Sub
Function transliterate(str As String, Lang As String, in_type As String) As String
Dim schema As Dictionary
Dim lang_swaras As String
Dim objtrans As Object
Dim outstr As String
Set objtrans = create_objTrans()
outstr = str
If in_type Like "[MTH]" Or Lang = "X" Then
transliterate = str
Exit Function
End If
If in_type = "N" Then
lang_swaras = Lang & "_swaras"
Set schema = build_schema(lang_swaras)
outstr = objtrans.convert_string(outstr, schema)
End If
Set schema = build_schema(Lang)
transliterate = objtrans.convert_string(outstr, schema)
End Function
Sub check_matra_count(i As Long, para As String)
Dim temp_array() As String
temp_array() = Split(para, "$")
If (UBound(temp_array) + 1) Mod TempVars!div_per_line > 0 Then
MsgBox TempVars!title & vbCrLf & "Matra count error in row " & i & " " & UBound(temp_array) + 1
End If
Erase temp_array
End Sub
Sub write_doc(p_type As String, p_para As String)
' need to take care of new text/comments/heading paragraphs
' need to take care of margins/sangathi count
Dim uline() As String
Dim uline_pos() As String
Dim from As Integer
Dim char_count As Integer
Dim i As Long, j As Long
p_para = Replace(Left(p_para, 1), Chr$(9), "") & Right(p_para, Len(p_para) - 1)
p_para = Replace(p_para, Chr$(10), "")
p_para = Replace(p_para, Chr$(12), "")
p_para = Replace(p_para, Chr$(13), "")
Select Case p_type
Case "T"
w.Selection.TypeText Text:=p_para
w.Selection.Style = w.ActiveDocument.Styles("n_title")
w.Selection.TypeParagraph
Case "H"
If w.Selection.Information(wdVerticalPositionRelativeToPage) + 76 > w.ActiveDocument.PageSetup.PageHeight - w.ActiveDocument.PageSetup.BottomMargin Then
w.Selection.InsertBreak Type:=wdPageBreak
End If
p_para = Replace(p_para, Chr$(9), " ")
w.Selection.TypeText Text:=p_para
w.Selection.Style = w.ActiveDocument.Styles("n_subhead")
w.Selection.TypeParagraph
Case "M"
w.Selection.TypeText Text:=p_para
w.Selection.Style = w.ActiveDocument.Styles("n_moorchana")
w.Selection.TypeParagraph
Case "L"
p_para = Replace(p_para, Chr$(9), " ")
w.Selection.TypeText Text:=p_para
w.Selection.Style = w.ActiveDocument.Styles("n_lyrics")
w.Selection.TypeParagraph
Case "S"
w.Selection.TypeText Text:=p_para
w.Selection.Style = w.ActiveDocument.Styles("sahityam")
w.Selection.TypeParagraph
Case "N"
' Tara Stayi line
'w.Selection.TypeText Text:=p_hi
w.Selection.Style = w.ActiveDocument.Styles("Hi_Octave")
'swara line
w.Selection.TypeParagraph
w.Selection.TypeText Text:=p_para
w.Selection.Style = w.ActiveDocument.Styles("Swara")
'duritha kalam
'uline() = Split(p_duritha, ",")
For j = 1 To UBound(uline)
If uline(j) <> "" Then
uline_pos() = Split(uline(j), "-")
from = uline_pos(0)
char_count = uline_pos(1)
w.Selection.HomeKey unit:=wdLine
w.Selection.MoveRight unit:=wdCharacter, Count:=from
w.Selection.MoveRight unit:=wdCharacter, Count:=char_count, Extend:=wdExtend
w.Selection.Font.Underline = wdUnderlineSingle
End If
Next j
w.Selection.EndKey unit:=wdLine
'Mandra stayi line
w.Selection.TypeParagraph
'w.Selection.TypeText Text:=p_lo
w.Selection.Style = w.ActiveDocument.Styles("Lo_Octave")
w.Selection.TypeParagraph
End Select
End Sub
Private Sub print_lyrics()
Dim rst As Recordset
Dim strheading As String
Set rst = CurrentDb.OpenRecordset("select * from lyrics " & _
" where " & TempVars!strfilter & _
" Order by Kriti, ragam, talam, seq")
strheading = " "
With rst
Do While Not .EOF
If strheading <> !Heading Then
strheading = !Heading
write_doc "H", strheading
End If
write_doc "L", !Lyric
'End If
.MoveNext
Loop
End With
End Sub
Sub notate_unic()
'
' start writing out notation in word document
'declarations
Dim gtype As String
Dim str_array() As String
Dim str_hi() As String
Dim str_lo() As String
Dim s As Integer, n As Integer, t As Long, k As Long
Dim i As Integer, c As String, chars As Integer, charCount As Integer
Dim nextc As String
Dim j As Integer, pcount As Integer, scount As Integer
Dim x As Integer
Dim tara As Boolean, mandra As Boolean, two As Boolean
Dim matra As Single, v_seq As String
Dim pre_c As Boolean, cur_c As Boolean, break As Boolean
Dim tala_part As Integer
Dim more As Long
ReDim Preserve paras(gparacnt)
ReDim Preserve para_hi(gparacnt)
ReDim Preserve para_lo(gparacnt)
ReDim Preserve para_type(gparacnt)
ReDim Preserve para_seq(gparacnt)
'code
'main do loop
more = 1
Do While more < UBound(paras)
'
' set of Lyrics records
'
For j = more To UBound(paras) Step 1
If para_type(j) = "S" Or para_type(j) = "N" Or para_type(j) = "" Then
Exit For
End If
more = j + 1
write_doc para_type(j), paras(j)
Next j
If more > UBound(paras) Then
Exit Do
End If
Erase Notation
n = 1
s = 2
For j = more To UBound(paras)
If para_type(j) <> "S" And para_type(j) <> "N" Then
Exit For
End If
' this is the place to force a break incase of
str_array = Split(paras(j), "$")
If para_type(j) = "N" Then
str_hi = Split(para_hi(j), "$")
str_lo = Split(para_lo(j), "$")
End If
Notation(n, 0) = para_seq(j)
t = 1
For k = 0 To UBound(str_array)
If para_type(j) = "N" Then
For x = 1 To Len(str_array(k))
c = Mid(str_array(k), x, 1)
If c <> "." And c <> "'" Then
Notation(n, t) = Notation(n, t) & c
End If
nextc = ""
If x < Len(str_array(k)) Then
nextc = Mid(str_array(k), x + 1, 1)
End If
If Trim(nextc) = "'" Then
Notation(n, t) = Notation(n, t) & ChrW(&H307) 'higher octave
ElseIf Trim(nextc) = "." Then
Notation(n, t) = Notation(n, t) & ChrW(&H323) ' lower octave
End If
Next x
'Notation(n, t) = str_hi(k)
'If Trim(str_hi(k)) = "." Then
' Notation(n, t) = str_array(k) & ChrW(&H307)
'ElseIf Trim(str_lo(k)) = "." Then
' Notation(n, t) = str_array(k) & ChrW(&H323)
'Else
' Notation(n, t) = str_array(k)
'Notation(n + 2, t) = str_lo(k)
'End If
Else
Notation(s, t) = str_array(k)
End If
t = t + 1
If t > TempVars!div_per_line Then
t = 1
If para_type(j) = "N" Then
'Notation(n, 50) = "Hi_Octave"
Notation(n, 50) = "Swara"
'Notation(n + 2, 50) = "Lo_Octave"
n = n + 2
Else
Notation(s, 50) = "sahityam"
s = s + 2
End If
End If
Next k
If t > 1 Then
t = 1
If para_type(j) = "N" Then
'Notation(n, 50) = "Hi_Octave"
Notation(n, 50) = "Swara"
'Notation(n + 2, 50) = "Lo_Octave"
n = n + 2
Else
Notation(s, 50) = "sahityam"
s = s + 2
End If
End If
more = j + 1
Next j
'
'call printing routine for N and S
'
print_notation_unic (n)
' print rouine
'
Loop
End Sub
Sub print_notation_unic(n As Long)
Dim vstr As String, i As Long
Dim nmatra As Integer, smatra As Integer
Dim eduppu As Integer
nmatra = 0
smatra = 0
eduppu = TempVars!Nadai
If TempVars!Talam = "Desadi" Then
eduppu = 6
End If
For i = 1 To n - 1 'notation lines
If Notation(i, 50) = "" Then
Exit For
End If
If Trim(Notation(i, 0)) <> "" Or nmatra <= eduppu Then ' i,0 has the sequence. This the place where it resets the matra
nmatra = 0
smatra = 0
End If
If Notation(i, 50) = "Swara" Then
If w.Selection.Information(wdVerticalPositionRelativeToPage) + 43 > w.ActiveDocument.PageSetup.PageHeight - w.ActiveDocument.PageSetup.BottomMargin Then
w.Selection.InsertBreak Type:=wdPageBreak
End If
End If
w.Selection.Style = w.ActiveDocument.Styles(Notation(i, 50))
Select Case Notation(i, 50)
Case "Swara"
Call Print_swara(i, nmatra)
Case "sahityam"
Call print_sahityam(i, smatra)
End Select
w.Selection.TypeParagraph
If Notation(i, 50) = "sahityam" Then DrawLine
Next i
End Sub
Function tala_division(matra As Integer) As Boolean
Dim i As Long
tala_division = False
For i = 0 To UBound(tala_structure)
If matra = tala_structure(i) * TempVars!Nadai Then
tala_division = True
End If
Next i
End Function
Sub Print_swara(i As Long, nmatra As Integer)
Dim chapu As Integer
Dim abc As String
Dim j As Long
Dim vstr As String
Dim uline As Single, ulineend As Single
Const kalam As Single = 1.4 'to get underline code
uline = 0
abc = ""
If TempVars!Talam Like "*Chapu" Then
chapu = TempVars!Nadai / 2
Else
chapu = 0
End If
For j = 0 To TempVars!div_per_line 'notations
If Notation(i, j) = "" And j > 0 Then
Exit For
End If
vstr = Replace(Notation(i, j), Chr(9), "")
' ***check*** moving to the end
'If j > 0 Then
' w.Selection.TypeText Text:=vbTab
'End If
'
' convert to abc notation
'
event_abc vstr, abc, keymap
Do While Left(vstr, 1) = "("
'If Left(Notation(i, j), 1) = "(" Then
vstr = Right(vstr, Len(vstr) - 1)
uline = uline + kalam
ulineend = uline
'End If
Loop
w.Selection.Font.Underline = uline
Do While Right(vstr, 1) = ")"
'If Right(Notation(i, j), 1) = ")" Then
vstr = Left(vstr, Len(vstr) - 1)
ulineend = ulineend - kalam
'w.Selection.Font.Underline = uline
'End If
Loop
'w.Selection.Font.Name = "Segoe UI Semibold"
w.Selection.Font.Name = TempVars!Notation_font
vstr = transliterate(vstr, TempVars!Lang, "N") ' version 5
w.Selection.TypeText Text:=vstr
' ***check*** moving to the end
' w.Selection.Font.Underline = wdUnderlineNone
If (j - chapu) / TempVars!Nadai = (j - chapu) \ TempVars!Nadai And j - chapu > 0 Then
w.Selection.Font.Underline = ulineend
w.Selection.TypeText Text:=vbTab
' single line nadai separator
w.Selection.InsertSymbol Font:="Arial Unicode MS", CharacterNumber:=9474, _
Unicode:=True
w.Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
w.Selection.Font.Color = -603923969
w.Selection.MoveRight unit:=wdCharacter, Count:=1
w.Selection.Font.Color = wdColorAutomatic
event_bar abc
End If
If j > 0 Then
nmatra = nmatra + 1
'End If
'==
If nmatra = TempVars!tala_cycle Then
' Double end of cycle
w.Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
w.Selection.Font.Color = wdColorAutomatic
w.Selection.InsertSymbol Font:="Arial Unicode MS", CharacterNumber:=9553, _
Unicode:=True
nmatra = 0
event_bar abc
Else
'==
'If j > 0 And j < tempvars!div_per_line Then
If tala_division(nmatra) Then
' single vertical
w.Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
w.Selection.Font.Color = wdColorAutomatic
w.Selection.InsertSymbol Font:="Arial Unicode MS", CharacterNumber:=9474, _
Unicode:=True
event_bar abc
End If
End If
End If
If j < TempVars!div_per_line Then
'If Left(Notation(i, j + 1), 1) <> "(" Then
w.Selection.Font.Underline = ulineend
uline = ulineend
'End If
w.Selection.TypeText Text:=vbTab
End If
Next j
add_abc abc
End Sub
Sub print_sahityam(i As Long, smatra As Integer)
Dim j As Long
Dim vstr As String
Dim chapu As Integer
If TempVars!Talam Like "*Chapu" Then
chapu = TempVars!Nadai / 2
Else
chapu = 0
End If
For j = 0 To TempVars!div_per_line 'notations
If Notation(i, j) = "" And j > 0 Then
Exit For
End If
vstr = Replace(Notation(i, j), ",", " ") 'beta version 3
If j > 0 Then
w.Selection.TypeText Text:=vbTab
End If
w.Selection.Font.Name = TempVars!Sahityam_font
vstr = transliterate(vstr, TempVars!Lang, "S") ' version 5
w.Selection.TypeText Text:=vstr
If (j - chapu) / TempVars!Nadai = (j - chapu) \ TempVars!Nadai And j - chapu > 0 Then
w.Selection.TypeText Text:=vbTab
End If