MWE below. Essentially what I am trying to do is to do a lookup of my 8cents delimited look-up-table text file for the purposes of converting from one type of musical notation to another.
The alphabetic input “do mi so la ti” should come out looking like a frequency in cents [000 400 700 900 1100], which corresponds to the first element of each line.
findall returns Cartesian indices of the row and column in which the original pitch input exists. I need to dereference just the row of the CartesianIndex because it is the first element of that row which decodes the frequency in cents. I don’t know how to do this.
Thanks,
Nakul
using DelimitedFiles
pitchcorpus = readdlm("8cents.txt")
pitchcorpus = string.(pitchcorpus)
Indexes = []
input = ["do" "mi" "so" "la" "ti"]
for i = 1:size(input,2)
mask = occursin.(input[i],pitchcorpus);
push!(Indexes,findall(mask))
end
Here is the textile 8cents.txt
000 C . Dbb B# do . ru ty S . sa .;
100 C# Db . . di ra . . R1 . ri .;
200 D . Ebb Cx re . mu dy R2 G1 ri ga;
300 D# Eb . . ri me . . R3 G2 ri ga;
400 E . Fb Dx mi . fu ry . G3 . ga;
500 F . Gbb E# fa . su my M1 . ma .;
600 F# Gb . . fi se . . M2 . ma .;
700 G . Abb Fx so . lu fy P . pa .;
800 G# Ab . . si le . . D1 . da .;
900 A . Bbb Gx la . tu sy D2 N1 da ni;
1000 A# Bb . . li te . . D3 N2 da ni;
1100 B . Cb Ax ti . du ly . N3 . ni;
1200 C . Dbb B# do . ru ty S . sa .;
1300 C# Db . . di ra . . R1 . ri .;
1400 D . Ebb Cx re . mu dy R2 G1 ri ga;
1500 D# Eb . . ri me . . R3 G2 ri ga;
1600 E . Fb Dx mi . fu ry . G3 . ga;
1700 F . Gbb E# fa . su my M1 . ma .;
1800 F# Gb . . fi se . . M2 . ma .;
1900 G . Abb Fx so . lu fy P . pa .;
2000 G# Ab . . si le . . D1 . da .;
2100 A . Bbb Gx la . tu sy D2 N1 da ni;
2200 A# Bb . . li te . . D3 N2 da ni;
2300 B . Cb Ax ti . du ly . N3 . ni;
2400 C . Dbb B# do . ru ty S . sa .;
2500 C# Db . . di ra . . R1 . ri .;
2600 D . Ebb Cx re . mu dy R2 G1 ri ga;
2700 D# Eb . . ri me . . R3 G2 ri ga;
2800 E . Fb Dx mi . fu ry . G3 . ga;
2900 F . Gbb E# fa . su my M1 . ma .;
3000 F# Gb . . fi se . . M2 . ma .;
3100 G . Abb Fx so . lu fy P . pa .;
3200 G# Ab . . si le . . D1 . da .;
3300 A . Bbb Gx la . tu sy D2 N1 da ni;
3400 A# Bb . . li te . . D3 N2 da ni;
3500 B . Cb Ax ti . du ly . N3 . ni;
3600 C . Dbb B# do . ru ty S . sa .;
3700 C# Db . . di ra . . R1 . ri .;
3800 D . Ebb Cx re . mu dy R2 G1 ri ga;
3900 D# Eb . . ri me . . R3 G2 ri ga;
4000 E . Fb Dx mi . fu ry . G3 . ga;
4100 F . Gbb E# fa . su my M1 . ma .;
4200 F# Gb . . fi se . . M2 . ma .;
4300 G . Abb Fx so . lu fy P . pa .;
4400 G# Ab . . si le . . D1 . da .;
4500 A . Bbb Gx la . tu sy D2 N1 da ni;
4600 A# Bb . . li te . . D3 N2 da ni;
4700 B . Cb Ax ti . du ly . N3 . ni;
4800 C . Dbb B# do . ru ty S . sa .;
4900 C# Db . . di ra . . R1 . ri .;
5000 D . Ebb Cx re . mu dy R2 G1 ri ga;
5100 D# Eb . . ri me . . R3 G2 ri ga;
5200 E . Fb Dx mi . fu ry . G3 . ga;
5300 F . Gbb E# fa . su my M1 . ma .;
5400 F# Gb . . fi se . . M2 . ma .;
5500 G . Abb Fx so . lu fy P . pa .;
5600 G# Ab . . si le . . D1 . da .;
5700 A . Bbb Gx la . tu sy D2 N1 da ni;
5800 A# Bb . . li te . . D3 N2 da ni;
5900 B . Cb Ax ti . du ly . N3 . ni;
6000 C . Dbb B# do . ru ty S . sa .;
6100 C# Db . . di ra . . R1 . ri .;
6200 D . Ebb Cx re . mu dy R2 G1 ri ga;
6300 D# Eb . . ri me . . R3 G2 ri ga;
6400 E . Fb Dx mi . fu ry . G3 . ga;
6500 F . Gbb E# fa . su my M1 . ma .;
6600 F# Gb . . fi se . . M2 . ma .;
6700 G . Abb Fx so . lu fy P . pa .;
6800 G# Ab . . si le . . D1 . da .;
6900 A . Bbb Gx la . tu sy D2 N1 da ni;
7000 A# Bb . . li te . . D3 N2 da ni;
7100 B . Cb Ax ti . du ly . N3 . ni;
7200 C . Dbb B# do . ru ty S . sa .;
7300 C# Db . . di ra . . R1 . ri .;
7400 D . Ebb Cx re . mu dy R2 G1 ri ga;
7500 D# Eb . . ri me . . R3 G2 ri ga;
7600 E . Fb Dx mi . fu ry . G3 . ga;
7700 F . Gbb E# fa . su my M1 . ma .;
7800 F# Gb . . fi se . . M2 . ma .;
7900 G . Abb Fx so . lu fy P . pa .;
8000 G# Ab . . si le . . D1 . da .;
8100 A . Bbb Gx la . tu sy D2 N1 da ni;
8200 A# Bb . . li te . . D3 N2 da ni;
8300 B . Cb Ax ti . du ly . N3 . ni;
8400 C . Dbb B# do . ru ty S . sa .;
8500 C# Db . . di ra . . R1 . ri .;
8600 D . Ebb Cx re . mu dy R2 G1 ri ga;
8700 D# Eb . . ri me . . R3 G2 ri ga;
8800 E . Fb Dx mi . fu ry . G3 . ga;
8900 F . Gbb E# fa . su my M1 . ma .;
9000 F# Gb . . fi se . . M2 . ma .;
9100 G . Abb Fx so . lu fy P . pa .;
9200 G# Ab . . si le . . D1 . da .;
9300 A . Bbb Gx la . tu sy D2 N1 da ni;
9400 A# Bb . . li te . . D3 N2 da ni;
9500 B . Cb Ax ti . du ly . N3 . ni;
9600 C . Dbb B# do . ru ty S . sa .;
9700 C# Db . . di ra . . R1 . ri .;
9800 D . Ebb Cx re . mu dy R2 G1 ri ga;
9900 D# Eb . . ri me . . R3 G2 ri ga;
10000 E . Fb Dx mi . fu ry . G3 . ga;
10100 F . Gbb E# fa . su my M1 . ma .;
10200 F# Gb . . fi se . . M2 . ma .;
10300 G . Abb Fx so . lu fy P . pa .;
10400 G# Ab . . si le . . D1 . da .;
10500 A . Bbb Gx la . tu sy D2 N1 da ni;
10600 A# Bb . . li te . . D3 N2 da ni;
10700 B . Cb Ax ti . du ly . N3 . ni;
10800 C . Dbb B# do . ru ty S . sa .;
10900 C# Db . . di ra . . R1 . ri .;
11000 D . Ebb Cx re . mu dy R2 G1 ri ga;
11100 D# Eb . . ri me . . R3 G2 ri ga;
11200 E . Fb Dx mi . fu ry . G3 . ga;
11300 F . Gbb E# fa . su my M1 . ma .;
11400 F# Gb . . fi se . . M2 . ma .;
11500 G . Abb Fx so . lu fy P . pa .;
11600 G# Ab . . si le . . D1 . da .;
11700 A . Bbb Gx la . tu sy D2 N1 da ni;
11800 A# Bb . . li te . . D3 N2 da ni;
11900 B . Cb Ax ti . du ly . N3 . ni;
12000 C . Dbb B# do . ru ty S . sa .;
12100 C# Db . . di ra . . R1 . ri .;
12200 D . Ebb Cx re . mu dy R2 G1 ri ga;
12300 D# Eb . . ri me . . R3 G2 ri ga;
12400 E . Fb Dx mi . fu ry . G3 . ga;
12500 F . Gbb E# fa . su my M1 . ma .;
12600 F# Gb . . fi se . . M2 . ma .;
12700 G . Abb Fx so . lu fy P . pa .;
Output: 5-element Array{Any,1}:
CartesianIndex{2}[CartesianIndex(1, 6), CartesianIndex(13, 6), CartesianIndex(25, 6), CartesianIndex(37, 6), CartesianIndex(49, 6), CartesianIndex(61, 6), CartesianIndex(73, 6), CartesianIndex(85, 6), CartesianIndex(97, 6), CartesianIndex(109, 6), CartesianIndex(121, 6)]
CartesianIndex{2}[CartesianIndex(5, 6), CartesianIndex(17, 6), CartesianIndex(29, 6), CartesianIndex(41, 6), CartesianIndex(53, 6), CartesianIndex(65, 6), CartesianIndex(77, 6), CartesianIndex(89, 6), CartesianIndex(101, 6), CartesianIndex(113, 6), CartesianIndex(125, 6)]
CartesianIndex{2}[CartesianIndex(8, 6), CartesianIndex(20, 6), CartesianIndex(32, 6), CartesianIndex(44, 6), CartesianIndex(56, 6), CartesianIndex(68, 6), CartesianIndex(80, 6), CartesianIndex(92, 6), CartesianIndex(104, 6), CartesianIndex(116, 6), CartesianIndex(128, 6)]
CartesianIndex{2}[CartesianIndex(10, 6), CartesianIndex(22, 6), CartesianIndex(34, 6), CartesianIndex(46, 6), CartesianIndex(58, 6), CartesianIndex(70, 6), CartesianIndex(82, 6), CartesianIndex(94, 6), CartesianIndex(106, 6), CartesianIndex(118, 6)]
CartesianIndex{2}[CartesianIndex(12, 6), CartesianIndex(24, 6), CartesianIndex(36, 6), CartesianIndex(48, 6), CartesianIndex(60, 6), CartesianIndex(72, 6), CartesianIndex(84, 6), CartesianIndex(96, 6), CartesianIndex(108, 6), CartesianIndex(120, 6)]