-
Notifications
You must be signed in to change notification settings - Fork 10
/
tabr-prog-notes.html
681 lines (655 loc) · 75.8 KB
/
tabr-prog-notes.html
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
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Note functions • tabr</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/cosmo/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="Note functions">
<meta property="og:description" content="tabr">
<meta property="og:image" content="https://leonawicz.github.io/tabr/logo.png">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">tabr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.4.5</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fas fa-home"></span>
Home
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Tutorials
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">Programming</li>
<li>
<a href="../articles/tabr-prog-nw.html">Noteworthiness</a>
</li>
<li>
<a href="../articles/tabr-prog-scales.html">Musical scales</a>
</li>
<li>
<a href="../articles/tabr-prog-notes.html">Note functions</a>
</li>
<li>
<a href="../articles/tabr-prog-chords.html">Chord functions</a>
</li>
<li>
<a href="../articles/tabr-prog-noteinfo.html">Time and note info</a>
</li>
<li>
<a href="../articles/tabr-prog-music.html">The music class</a>
</li>
<li>
<a href="../articles/tabr-prog-converters.html">Syntax converters</a>
</li>
<li>
<a href="../articles/tabr-fretboard.html">Fretboard diagram plots</a>
</li>
<li class="divider">
<li class="dropdown-header">Transcription</li>
<li>
<a href="../articles/tabr-basics.html">Basic overview</a>
</li>
<li>
<a href="../articles/tabr-phrases.html">Musical phrases</a>
</li>
<li>
<a href="../articles/tabr-helpers.html">Phrase helpers</a>
</li>
<li>
<a href="../articles/tabr-chords.html">Chords</a>
</li>
<li>
<a href="../articles/tabr-repeats.html">Repeats</a>
</li>
<li>
<a href="../articles/tabr-tracks-scores.html">Tracks and scores</a>
</li>
<li>
<a href="../articles/tabr-engraving.html">Render scores</a>
</li>
<li>
<a href="../articles/tabr-snippets.html">Music snippets</a>
</li>
<li>
<a href="../articles/tabr-chordchart.html">Render chord chart</a>
</li>
<li>
<a href="../articles/tabr-tunings.html">Strings and tunings</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Examples
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/tabr-ex1.html">Tuning and capo</a>
</li>
<li>
<a href="../articles/tabr-ex2.html">Multiple voices</a>
</li>
<li>
<a href="../articles/tabr-ex3.html">AC2 - Ezio's family</a>
</li>
<li>
<a href="../articles/tabr-ex4.html">Gin Wigmore - Devil in me</a>
</li>
</ul>
</li>
<li>
<a href="../reference/index.html">Reference</a>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/leonawicz/tabr">
<span class="fas fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><script src="tabr-prog-notes_files/accessible-code-block-0.0.1/empty-anchor.js"></script><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1 data-toc-skip>Note functions</h1>
<small class="dont-index">Source: <a href="https://github.com/leonawicz/tabr/blob/master/vignettes/tabr-prog-notes.Rmd"><code>vignettes/tabr-prog-notes.Rmd</code></a></small>
<div class="hidden name"><code>tabr-prog-notes.Rmd</code></div>
</div>
<div id="note-identity-checks" class="section level2">
<h2 class="hasAnchor">
<a href="#note-identity-checks" class="anchor"></a>Note identity checks</h2>
<p>There are a number of functions that assist with music programming around note and pitch validation, comparison, equivalence checking, and various manipulations and transformations. In a previous section, you saw <code>is_note</code> and <code>is_chord</code>. Other identity functions include:</p>
<ul>
<li><code>note_has_natural</code></li>
<li><code>note_has_accidental</code></li>
<li><code>note_has_flat</code></li>
<li><code>note_has_sharp</code></li>
<li><code>note_is_natural</code></li>
<li><code>note_is_accidental</code></li>
<li><code>note_is_flat</code></li>
<li><code>note_is_sharp</code></li>
<li><code>note_has_tick</code></li>
<li><code>note_has_integer</code></li>
<li><code>note_is_tick</code></li>
<li><code>note_is_integer</code></li>
<li><code>is_diatonic</code></li>
</ul>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"c e_ g b_"</span>
<span class="fu"><a href="../reference/note-checks.html">note_has_accidental</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] TRUE
</code></pre>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-checks.html">note_is_accidental</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] FALSE TRUE FALSE TRUE
</code></pre>
<p>The function <code>is_diatonic</code> takes a <code>key</code> signature for context.</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"c e_ g b_ cd#g"</span>
<span class="fu"><a href="../reference/is_diatonic.html">is_diatonic</a></span><span class="op">(</span><span class="va">x</span>, key <span class="op">=</span> <span class="st">"c"</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] TRUE FALSE TRUE FALSE FALSE
</code></pre>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/is_diatonic.html">is_diatonic</a></span><span class="op">(</span><span class="va">x</span>, key <span class="op">=</span> <span class="st">"b_"</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] TRUE TRUE TRUE TRUE FALSE
</code></pre>
</div>
<div id="noteworthy-string-metadata" class="section level2">
<h2 class="hasAnchor">
<a href="#noteworthy-string-metadata" class="anchor"></a>Noteworthy string metadata</h2>
<p>There are a number of functions that parse basic metadata about noteworthy strings.</p>
<ul>
<li><code>n_steps</code></li>
<li><code>n_notes</code></li>
<li><code>n_chords</code></li>
<li><code>n_octaves</code></li>
<li><code>chord_size</code></li>
<li><code>octave_type</code></li>
<li><code>accidental_type</code></li>
<li><code>time_format</code></li>
<li><code>is_space_time</code></li>
<li><code>is_vector_time</code></li>
</ul>
<p>See <code><a href="../reference/note-metadata.html">help("note-metadata")</a></code> for details. A few examples are shown here.</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"e_2 a_, c#f#a#"</span>
<span class="fu"><a href="../reference/note-metadata.html">n_steps</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] 3
</code></pre>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-metadata.html">n_notes</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] 2
</code></pre>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-metadata.html">n_chords</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] 1
</code></pre>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-metadata.html">chord_size</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] 1 1 3
</code></pre>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-metadata.html">octave_type</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] "tick"
</code></pre>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-metadata.html">time_format</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] "space-delimited time"
</code></pre>
</div>
<div id="noteworthy-string-summaries" class="section level2">
<h2 class="hasAnchor">
<a href="#noteworthy-string-summaries" class="anchor"></a>Noteworthy string summaries</h2>
<p>While there is not a clear delineation between the previous set of functions and the next, it helps to break them up a bit since there are many. These functions go bit further in summarizing the data in noteworthy strings.</p>
<ul>
<li><code>tally_notes</code></li>
<li><code>tally_pitches</code></li>
<li><code>octaves</code></li>
<li><code>tally_octaves</code></li>
<li><code>distinct_notes</code></li>
<li><code>distinct_pitches</code></li>
<li><code>distinct_octaves</code></li>
<li><code>pitch_range</code></li>
<li><code>semitone_range</code></li>
<li><code>semitone_span</code></li>
<li><code>octave_range</code></li>
<li><code>octave_span</code></li>
</ul>
<p>See <code><a href="../reference/note-summaries.html">help("note-summaries")</a></code> for details. Here are some examples.</p>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"e_2 a_, b_, c#f#a# c#'f#'a#''"</span>
<span class="fu"><a href="../reference/note-summaries.html">tally_notes</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;"># A tibble: 6 x 2</span><span>
#> note n
#> </span><span style="color: #555555;font-style: italic;"><chr></span><span> </span><span style="color: #555555;font-style: italic;"><int></span><span>
#> </span><span style="color: #555555;">1</span><span> c# 2
#> </span><span style="color: #555555;">2</span><span> e_ 1
#> </span><span style="color: #555555;">3</span><span> f# 2
#> </span><span style="color: #555555;">4</span><span> a_ 1
#> </span><span style="color: #555555;">5</span><span> a# 2
#> </span><span style="color: #555555;">6</span><span> b_ 1
</span></code></pre>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-summaries.html">tally_pitches</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;"># A tibble: 9 x 2</span><span>
#> pitch n
#> </span><span style="color: #555555;font-style: italic;"><chr></span><span> </span><span style="color: #555555;font-style: italic;"><int></span><span>
#> </span><span style="color: #555555;">1</span><span> e_2 1
#> </span><span style="color: #555555;">2</span><span> a_, 1
#> </span><span style="color: #555555;">3</span><span> b_, 1
#> </span><span style="color: #555555;">4</span><span> c# 1
#> </span><span style="color: #555555;">5</span><span> f# 1
#> </span><span style="color: #555555;">6</span><span> a# 1
#> </span><span style="color: #555555;">7</span><span> c#' 1
#> </span><span style="color: #555555;">8</span><span> f#' 1
#> </span><span style="color: #555555;">9</span><span> a#'' 1
</span></code></pre>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-summaries.html">distinct_notes</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">d_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span>
</span></code></pre>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-summaries.html">distinct_pitches</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d_</span><span style="color: #00BBBB;">'</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">'</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">''</span><span>
</span></code></pre>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-summaries.html">pitch_range</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] "e_," "b_''"
</code></pre>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-summaries.html">semitone_range</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] 39 82
</code></pre>
</div>
<div id="coercion-functions" class="section level2">
<h2 class="hasAnchor">
<a href="#coercion-functions" class="anchor"></a>Coercion functions</h2>
<div id="accidentals" class="section level3">
<h3 class="hasAnchor">
<a href="#accidentals" class="anchor"></a>Accidentals</h3>
<p>Note that it is common for functions to treat notes as different if they sound the same but one is transcribed as a flat and the other as a sharp. <code>tabr</code> makes the distinction for notation purposes; same pitch, different notes. This also supports transcription. Functions like <code>transpose</code> of course handle pitch as pitch and therefore the style of representation does not affect computation.</p>
<p>There are functions for enforcing a singular representation for accidentals in noteworthy strings since it is unusual to mix flats and sharps.</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-coerce.html">flatten_sharp</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">d_g_b_</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">d_</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-coerce.html">sharpen_flat</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">d#</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g#</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a#</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c#f#a#</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c#</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">f#</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">a#</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p>Do not be confused about the names of these functions. They are for enforcing a single type of accidental. To actually lower sharps by a half step or semitone as well as raise flats similarly, use <code>naturalize</code>.</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-coerce.html">naturalize</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">e</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">cfa</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">f</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p>These are helpful building blocks for music programming. A useful wrapper around <code>flatten_sharp</code> and <code>sharpen_flat</code> is <code>note_set_key</code>. Like <code>is_diatonic</code>, this function takes a <code>key</code> argument. <code>key</code> was more meaningful for <code>is_diatonic</code>. However, providing a key signature here is helpful for the purpose of enforcing the correct representation of accidentals intended by the user, which <code>tabr</code> cannot know until informed.</p>
<p>Be aware that the default for functions that take a <code>key</code> argument is <code>c</code>, but <code>c</code> and <code>am</code> have no accidentals in their key signatures, so <code>note_set_key</code> will have no effect if you pass these values to <code>key</code>. It is also important to recognize that it does not matter for this function what key you choose specifically; it only matters that you choose a key that has the type of accidentals in its signature that you wish to force your noteworthy string to use. If you want flats, it makes no difference if you set <code>key = "f"</code> or <code>key = "b_"</code>. For this function, you can also literally enter <code>key = "flat"</code> or <code>key = "sharp"</code>, options that stress the extent to which <code>key</code> actually matters to <code>note_set_key</code>.</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-coerce.html">note_set_key</a></span><span class="op">(</span><span class="va">x</span>, <span class="st">"c"</span><span class="op">)</span> <span class="co"># no change possible</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">d_g_b_</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">d_</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-coerce.html">note_set_key</a></span><span class="op">(</span><span class="va">x</span>, <span class="st">"f"</span><span class="op">)</span> <span class="co"># key of F has a flat</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">d_g_b_</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">d_</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-coerce.html">note_set_key</a></span><span class="op">(</span><span class="va">x</span>, <span class="st">"g"</span><span class="op">)</span> <span class="co"># key of G has a sharp</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">d#</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g#</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a#</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c#f#a#</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c#</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">f#</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">a#</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p>The intent is not to force notes which may not be diatonic to the key signature to fit that signature. All pitches remain exactly what they are. It does not matter if they are not in the key. But they are forced to conform to a key’s representation of accidentals.</p>
<p>For other functions in <code>tabr</code>, <code>key</code> arguments utilize the specific key signature in a more complete manner, and the options <code>flat</code> and <code>sharp</code> are not relevant or allowed.</p>
</div>
<div id="octave-numbering" class="section level3">
<h3 class="hasAnchor">
<a href="#octave-numbering" class="anchor"></a>Octave numbering</h3>
<p>Octave numbering can be ambiguous, including both tick and integer numbering format. You can coerce a noteworthy string strictly to one of the other:</p>
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"c, c c' c2 c c4"</span>
<span class="fu"><a href="../reference/note-coerce.html">as_integer_octaves</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">2</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">4</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">2</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">4</span><span>
</span></code></pre>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-coerce.html">as_tick_octaves</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span>
</span></code></pre>
<p>In general, functions that operate on and return noteworthy strings will perform coercion to an internally consistent format. If formatting is ambiguous, the default is tick octave numbering and flats for accidentals.</p>
</div>
<div id="timestep-format" class="section level3">
<h3 class="hasAnchor">
<a href="#timestep-format" class="anchor"></a>Timestep format</h3>
<p>Similarly, you can coerce the time format of a noteworthy string between space-delimited time and vectorized time:</p>
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="op">(</span><span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/note-coerce.html">as_space_time</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"c"</span>, <span class="st">"e"</span>, <span class="st">"g"</span>, <span class="st">"ceg"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ceg</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="op">(</span><span class="va">y</span> <span class="op"><-</span> <span class="fu"><a href="../reference/note-coerce.html">as_vector_time</a></span><span class="op">(</span><span class="st">"c e g ceg"</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>vectorized time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ceg</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] "c e g ceg"
</code></pre>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] "c" "e" "g" "ceg"
</code></pre>
</div>
</div>
<div id="comparative-equivalence" class="section level2">
<h2 class="hasAnchor">
<a href="#comparative-equivalence" class="anchor"></a>Comparative equivalence</h2>
<p>The <code>note_is_*</code> functions mentioned earlier are vectorized, but the operations they perform are self checks. Other functions are available for comparative checks of identity or equivalence between two notes. These functions are also vectorized. Each note input can be an entire noteworthy string.</p>
<p>There are different dimensions along which the strictness of equality varies and are worth taking a moment to break these and other properties down clearly:</p>
<ul>
<li>These functions come in <code>*_is_equal</code> and <code>*is_identical</code> pairs. Equality is more relaxed than identity.</li>
<li>The <code>note_is_*</code> pairs below also offer the argument <code>ignore_octave</code>. This further weakens the requirements for passing both equality and identity comparisons of two notes.</li>
<li>These functions perform a noteworthy check, but do not require anything stricter. This means these comparisons work on all notes, even those belonging to chords.</li>
<li>The general distinction between notes being equal and notes being identical is sound vs. transcription/written notation. If two notes sound the same, e.g. <code>e_</code> and <code>d#</code>, they are equal, but not identical.</li>
<li>There are additional nuances with octave comparisons using the <code>octave_is_*</code> pairs.</li>
</ul>
<p>First look at note and pitch comparisons. The main difference is that pitch is more complete than note in that the former implicitly carries the octave position. Setting <code>ignore_octave = FALSE</code> for note comparisons makes them equivalent to their pitch comparison counterparts.</p>
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"b_2 ce_g"</span>
<span class="va">y</span> <span class="op"><-</span> <span class="st">"b_ cd#g"</span>
<span class="fu"><a href="../reference/note-equivalence.html">note_is_equal</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] TRUE TRUE
</code></pre>
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-equivalence.html">note_is_identical</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] TRUE FALSE
</code></pre>
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="fu"><a href="../reference/note-equivalence.html">pitch_is_equal</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] FALSE TRUE
</code></pre>
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-equivalence.html">pitch_is_identical</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] FALSE FALSE
</code></pre>
<p>There are minimal requirements for equivalence that precede the forms and degrees of equivalence described and shown above. At a bare minimum, two noteworthy strings must have the same number of time steps available for pairwise comparison. Otherwise a simple <code>NA</code> is returned. In the following example, the strings <code>x</code> and <code>y</code> have the same number of notes, in the same order, but the first has three times steps and the second has two.</p>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"b_2 ce_g b_"</span>
<span class="va">y</span> <span class="op"><-</span> <span class="st">"b_2 ce_gb_"</span>
<span class="fu"><a href="../reference/note-equivalence.html">note_is_equal</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] NA
</code></pre>
<p>In the next example, <code>x</code> and <code>y</code> have the same number of of the same notes, again in the same order, and even have an equal number of timesteps. Having the same number of timesteps makes pairwise comparisons possible. They return <code>FALSE</code> where unequal.</p>
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"b_2 ce_g b_"</span>
<span class="va">y</span> <span class="op"><-</span> <span class="st">"b_2 ce_ gb_"</span>
<span class="fu"><a href="../reference/note-equivalence.html">note_is_equal</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] TRUE FALSE FALSE
</code></pre>
<p>Finally, there are octave comparisons, which must be defined and behave somewhat differently. <code>octave_is_equal</code> and <code>octave_is_identical</code> allow much weaker forms of equivalence in that they ignore notes completely. These functions are only concerned with comparing the octave numbers spanned by any pitches present at each timestep.</p>
<p>When checking for equality, <code>octave_is_equal</code> only looks at the octave number associated with the first note at each step, e.g., only the root note of a chord. <code>octave_is_identical</code> compares all octaves spanned at a given timestep by considering all notes when a chord is present.</p>
<p>This still leaves open the definitions of equivalence. To clarify:</p>
<ul>
<li>It does not matter when comparing two chords that they may be comprised of a different numbers of notes.</li>
<li>If the set of unique octaves spanned by one chord is identical to the set spanned by the other, they are considered to have identical octave coverage.</li>
</ul>
<p>Consider an example: <code>a1b2c3</code> is identical to <code>d1e1f2g3</code>. The notes are irrelevant. The number of notes is irrelevant. The fact that octave number one occurs a different number of times in each chord is irrelevant. What matters is that they both have the same set of unique octave positions <code>{1, 2, 3}</code>. To be equal, even less is required. In this case it only matters that the two chords begin with <code>x1</code>, where <code>x</code> is any note.</p>
<p>One alternative, for <code>octave_is_identical</code> only, is to set <code>single_octave = TRUE</code>. This increases the requirement for identity to require that all notes from both chords being compared at a given timestep share a single octave.</p>
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"a1 b_2 a1b2c3 a1b4 g1a1b1"</span>
<span class="va">y</span> <span class="op"><-</span> <span class="st">"a_2 g#2 d1e1f2g3 a1b2b4 d1e1"</span>
<span class="fu"><a href="../reference/note-equivalence.html">octave_is_equal</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] FALSE TRUE TRUE TRUE TRUE
</code></pre>
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-equivalence.html">octave_is_identical</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] FALSE TRUE TRUE FALSE TRUE
</code></pre>
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note-equivalence.html">octave_is_identical</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span>, single_octave <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] FALSE TRUE FALSE FALSE TRUE
</code></pre>
</div>
<div id="slice-sort-rotate-shift-arpeggiate" class="section level2">
<h2 class="hasAnchor">
<a href="#slice-sort-rotate-shift-arpeggiate" class="anchor"></a>Slice, sort, rotate, shift, arpeggiate</h2>
<p>A noteworthy string can be subset by index. This can with specific integers or with a logical vector with the same length as the number of time steps.</p>
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"a b ceg"</span>
<span class="fu"><a href="../reference/note_slice.html">note_slice</a></span><span class="op">(</span><span class="va">x</span>, <span class="fl">2</span><span class="op">:</span><span class="fl">3</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ceg</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_slice</a></span><span class="op">(</span><span class="va">x</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">FALSE</span>, <span class="cn">TRUE</span>, <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ceg</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p>Vectorized time is more trivial but is of course handled the same way and still applies the noteworthiness check and class assignment.</p>
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"a"</span>, <span class="st">"b"</span>, <span class="st">"ceg"</span><span class="op">)</span>
<span class="fu"><a href="../reference/note_slice.html">note_slice</a></span><span class="op">(</span><span class="va">x</span>, <span class="fl">2</span><span class="op">:</span><span class="fl">3</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>vectorized time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ceg</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_slice</a></span><span class="op">(</span><span class="va">x</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">FALSE</span>, <span class="cn">TRUE</span>, <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>vectorized time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ceg</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p>Sorting by pitch works with chords by sorting successively across notes in a chord. For example, <code>a,</code> is sorted lower than <code>a,ce</code>, which in turn is lower than <code>a,e</code>. Below is an example where notes and chords are not sorted by pitch. The final chord in the sequence also spans three octaves. There is also a <code>ba</code>, which is itself not ordered, but this is accounted for when sorting by successive pitches in chords.</p>
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op"><-</span> <span class="st">"bd'f#' a c'e'g' b ba c'g' gd'g'd''"</span>
<span class="fu"><a href="../reference/note_slice.html">note_sort</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">gd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ba</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">bd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">f#</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">e</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_sort</a></span><span class="op">(</span><span class="va">x</span>, decreasing <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">e</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">bd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">f#</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ba</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">gd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p>Rotating or cycling a sequence of notes and chords in a noteworthy string is done with <code>note_rotate</code>. This is a simple function. It only rotates the sequence left or right. It does not do any transposition. It does not break chords, but rather rotates them intact.</p>
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_rotate</a></span><span class="op">(</span><span class="va">x</span>, <span class="fl">1</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">a</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">e</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ba</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">gd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">bd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">f#</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_rotate</a></span><span class="op">(</span><span class="va">x</span>, <span class="op">-</span><span class="fl">1</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">gd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">''</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">bd</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">f#</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">e</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">ba</span><span style="color: #BBBB00;">></span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">'</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p><code>note_shft</code> also rotates notes, but does so up or down in pitch like a moving window. It requires breaking any chords into separate notes, ordering all notes by pitch, and then shifting the sorted notes <code>n</code> times, negative or positive indicating the direction.</p>
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_shift</a></span><span class="op">(</span><span class="st">"c e g"</span>, <span class="fl">1</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">e</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span>
</span></code></pre>
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_shift</a></span><span class="op">(</span><span class="st">"c e g"</span>, <span class="op">-</span><span class="fl">4</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">g</span><span style="color: #00BBBB;">,,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e</span><span style="color: #00BBBB;">,</span><span>
</span></code></pre>
<p><code>note_arpeggiate</code> is like <code>note_shift</code> but it repeats the entire sequence rather than shifting it a note at a time and maintaining its fixed size. <code>n</code> refers to the number of repeats and must be positive. <code>steps</code> refers to the semitone offset.</p>
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_arpeggiate</a></span><span class="op">(</span><span class="st">"c e_ g_ a"</span>, <span class="fl">3</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">'</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">'</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">'</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">'''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">'''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">'''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">'''</span><span>
</span></code></pre>
<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/note_slice.html">note_arpeggiate</a></span><span class="op">(</span><span class="st">"c e_ g_ a"</span>, <span class="fl">3</span>, <span class="op">-</span><span class="fl">3</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">e_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">g_</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">,</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span>
</span></code></pre>
</div>
<div id="transpose" class="section level2">
<h2 class="hasAnchor">
<a href="#transpose" class="anchor"></a>Transpose</h2>
<p>An important function in <code>tabr</code> for manipulating music notation is the <code>transpose</code> function, which also has the alias <code>tp</code>.</p>
<div class="sourceCode" id="cb50"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">notes1</span> <span class="op"><-</span> <span class="st">"c3 b2 c3 d3 e3 e3 d3 c3 b2 c3 c3 c4"</span>
<span class="va">notes2</span> <span class="op"><-</span> <span class="st">"c4 b c4 d4 e4 e4 d4 c4 b c4 c4 c5"</span>
<span class="fu"><a href="../reference/transpose.html">transpose</a></span><span class="op">(</span><span class="va">notes1</span>, <span class="fl">12</span>, octaves <span class="op">=</span> <span class="st">"integer"</span><span class="op">)</span> <span class="op">==</span> <span class="fu"><a href="../reference/valid-notes.html">as_noteworthy</a></span><span class="op">(</span><span class="va">notes2</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
</code></pre>
<p>Transposing down is done with negative integers.</p>
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">transpose</a></span><span class="op">(</span><span class="st">"a_3 b_4 c5"</span>, <span class="fl">0</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">a_</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b_</span><span style="color: #00BBBB;">4</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">5</span><span>
</span></code></pre>
<div class="sourceCode" id="cb52"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a_3 b_4 c5"</span>, <span class="op">-</span><span class="fl">1</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">g</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">4</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span style="color: #00BBBB;">4</span><span>
</span></code></pre>
<div class="sourceCode" id="cb53"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a_3 b_4 c5"</span>, <span class="fl">1</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">a</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span style="color: #00BBBB;">4</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d_</span><span style="color: #00BBBB;">5</span><span>
</span></code></pre>
<div class="sourceCode" id="cb54"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a#3 b4 c#5"</span>, <span class="fl">11</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">4</span><span> </span><span style="color: #00BBBB;font-weight: bold;">a#</span><span style="color: #00BBBB;">5</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">6</span><span>
</span></code></pre>
<div class="sourceCode" id="cb55"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a#3 b4 c#5"</span>, <span class="op">-</span><span class="fl">12</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">a#</span><span style="color: #00BBBB;">2</span><span> </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c#</span><span style="color: #00BBBB;">4</span><span>
</span></code></pre>
<div class="sourceCode" id="cb56"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a#3 b4 c#5"</span>, <span class="fl">13</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span style="color: #00BBBB;">4</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c</span><span style="color: #00BBBB;">6</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">6</span><span>
</span></code></pre>
<p><code>transpose</code> also offers the arguments found in <code>as_noteworthy</code> for direct control over the format of the transposed output. You can specify the key signature with <code>key</code> as an optional override to <code>accidentals</code>. It does not do anything more than enforce the desired format for accidentals.</p>
<div class="sourceCode" id="cb57"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a3 b4 c5"</span>, <span class="fl">2</span>, key <span class="op">=</span> <span class="st">"f"</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d_</span><span style="color: #00BBBB;">5</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">5</span><span>
</span></code></pre>
<div class="sourceCode" id="cb58"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a3 b4 c5"</span>, <span class="fl">2</span>, octaves <span class="op">=</span> <span class="st">"tick"</span>, key <span class="op">=</span> <span class="st">"g"</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c#</span><span style="color: #00BBBB;">''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">''</span><span>
</span></code></pre>
<div class="sourceCode" id="cb59"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a b' c''"</span>, <span class="fl">2</span>, accidentals <span class="op">=</span> <span class="st">"flat"</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d_</span><span style="color: #00BBBB;">''</span><span> </span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">''</span><span>
</span></code></pre>
<div class="sourceCode" id="cb60"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/transpose.html">tp</a></span><span class="op">(</span><span class="st">"a, b c'e'g'"</span>, <span class="fl">2</span>, octaves <span class="op">=</span> <span class="st">"integer"</span>, accidentals <span class="op">=</span> <span class="st">"sharp"</span><span class="op">)</span></code></pre></div>
<pre class="r-output"><code>#> <span style="color: #555555;font-weight: bold;"><Noteworthy string>
#> Format: </span><span>space-delimited time</span><span style="color: #555555;font-weight: bold;">
#> Values: </span><span style="color: #00BBBB;font-weight: bold;">b</span><span style="color: #00BBBB;">2</span><span> </span><span style="color: #00BBBB;font-weight: bold;">c#</span><span style="color: #00BBBB;">4</span><span> </span><span style="color: #BBBB00;"><</span><span style="color: #00BBBB;font-weight: bold;">d</span><span style="color: #00BBBB;">4</span><span style="color: #00BBBB;font-weight: bold;">f#</span><span style="color: #00BBBB;">4</span><span style="color: #00BBBB;font-weight: bold;">a</span><span style="color: #00BBBB;">4</span><span style="color: #BBBB00;">></span><span>
</span></code></pre>
<p><code>transpose</code> also works when chords are present. The next section on music programming covers various functions related to chords.</p>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
</nav>
</div>
</div>
<footer><div class="copyright">
<p>Developed by <a href="https://github.com/leonawicz">Matthew Leonawicz</a>.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
</div>
</body>
</html>