-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathREADME.Rmd
More file actions
107 lines (82 loc) · 3.08 KB
/
README.Rmd
File metadata and controls
107 lines (82 loc) · 3.08 KB
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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "70%",
fig.width = 6,
fig.height = 3,
dpi = 300
)
```
# Representing harmony with the hrep package
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://travis-ci.org/pmcharrison/hrep)
[](https://ci.appveyor.com/project/pmcharrison/hrep)
[](https://coveralls.io/r/pmcharrison/hrep?branch=master)
[](https://doi.org/10.5281/zenodo.2545770)
The *hrep* R package provides utilities for representing and manipulating
chord sequences for perceptually informed harmony modelling.
The available representations include symbolic representations,
acoustic representations, and sensory representations.
Integer encodings are defined for several symbolic representations,
allowing the user to efficiently express chord sequences as sequences
of integers.
## Resources
- [Function-level documentation](https://pmcharrison.github.io/hrep/reference/index.html)
- [Changelog](https://pmcharrison.github.io/hrep/news/index.html)
- [File an issue](https://github.com/pmcharrison/hrep/issues)
- [Music corpora](https://github.com/pmcharrison/hcorp)
- [Models of simultaneous consonance](https://github.com/pmcharrison/incon)
- [Automatic voicing of chord sequences](https://github.com/pmcharrison/voicer)
## Installation
The *hrep* package may be installed from GitHub as follows:
``` r
if (!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("pmcharrison/hrep")
```
## Example usage
Chords may be defined as sequences of integers, with each integer
corresponding to a pitch or a pitch class.
The following chord defines a C major triad in first inversion:
```{r}
library(hrep)
x <- pi_chord(c(52, 60, 67))
print(x)
```
From this symbolic representation, it is possible to derive various
acoustic and sensory representations, such as:
a) A wave:
```{r}
plot(wave(x))
```
b) A sparse pitch spectrum:
```{r}
plot(sparse_pi_spectrum(x))
```
c) A sparse pitch-class spectrum:
```{r}
plot(sparse_pc_spectrum(x))
```
d) A smooth pitch-class spectrum:
```{r}
plot(smooth_pc_spectrum(x))
```
Chords can be translated to various symbolic representations,
which can be encoded to integer formats.
For example, here we convert the chord to the pitch-class chord representation,
and then encode it to an integer.
```{r}
pc_chord((x))
as.integer(encode(pc_chord(x)))
```
Similarly, the following code expresses the chord as a pitch-class set,
and then encodes the pitch-class set as an integer.
```{r}
pc_set(x)
as.integer(encode(pc_set(x)))
```