resful apl_我对apl的音乐介绍

resful apl

My musical life and computer programming life cross paths frequently. I probably was interested in computers first, but I got seriously into programming later in life when I started doing it for my music. I oscillate back and forth between the two — either focused just on one or the other but often combining the two equally. Recently I’ve been focused on programming, but I found a bridge back to music by way of learning about a new (to me) programming language.

我的音乐生活和计算机编程生活经常会跨越道路。 我最初可能对计算机感兴趣,但是后来我开始为音乐创作时就认真地进行编程。 我在两者之间来回摆动-要么只专注于另一个,要么常常将两者平等地结合在一起。 最近,我一直专注于编程,但是通过学习一种新的编程语言(对我而言),我找到了通向音乐的桥梁。

I didn’t know anything about APL when I started looking into it, other than that I’ve seen it referenced in books and articles as one of those “interesting languages to look into.” It’s recommended as a language you might want to study for its unique perspective, as opposed to its practical application in today’s world. APL is the acronym for the self-descriptive and literal name of the language — A Programming Language. It was developed in the 1960s by Kenneth Iverson as a mathematical notation designed specifically for working with arrays and matrices — with the intent to create a programming language using the same notation.

当我开始研究APL时,我对它一无所知,除了我在书和文章中看到它是那些“值得研究的语言”之一。 推荐使用它作为您可能要学习的一种语言,因为它具有独特的视角,而不是当今世界的实际应用。 APL是该语言的自描述性和文字名称的缩写-一种编程语言。 它是由肯尼斯·艾弗森(Kenneth Iverson)在1960年代开发的,它是一种专门为处理数组和矩阵而设计的数学符号-旨在使用相同的符号创建一种编程语言。

The first thing that caught my attention was the alphabet of symbols. Though most languages include the basic math symbols (+, -, /, *), APL is almost exclusively symbols such as ⌽, ⌿, ÷, ≢, |.

引起我注意的第一件事是符号字母。 尽管大多数语言都包含基本的数学符号(+,-,/,*),但是APL几乎完全是诸如⌽,⌿,÷,≢,|等符号。

The second thing that caught my attention was that APL uses a matrix as the main data-type. This particularly piqued my interest, since a matrix (and it’s 1-dimensional counterpart: an array) is great for working with groups of musical notes. I had in mind the 20th-century music theory used in serialist music (serialism). Serialism seeks to treat all 12 notes equally by placing them in a particular order and not repeating any notes until all have been played once*. The resulting order of notes is called a “tone row”, and in mathematical terms, we can call it an array. In this system, we represent notes with the numbers from 0 to 11. Each number represents a “pitch class”, or in other words just the note name, and not the octave or register in which it is played.

引起我注意的第二件事是APL使用矩阵作为主要数据类型。 这特别激起了我的兴趣,因为矩阵(和一维对应项:数组)非常适合处理音符组。 我想到了20世纪序列论音乐(串行主义)中使用的音乐理论。 序列主义试图通过将所有12个音符按特定顺序放置,而不重复任何音符直到所有音符都演奏一次*来平等对待。 音符的最终顺序称为“音行”,用数学术语来说,我们可以称其为数组。 在此系统中,我们用从0到11的数字表示音符。每个数字代表一个“音高类”,或者换句话说就是音符名称,而不是在其中演奏的八度或寄存器。

For example, here is a tone row — shown as notes on a staff, note names, and numbers:

例如,这是一个音调行-显示为谱号上的音符,音符名称和数字:

The numerical relationships translate directly into musical harmonic and melodic relationships. You can apply mathematical operations to that array to produce a number of variations that derive from those. APL is able to easily create these variations because it deals primarily with data represented in the same way.

数值关系直接转化为和声和旋律关系。 您可以将数学运算应用于该数组以产生许多衍生自这些数组的变体。 APL能够轻松创建这些变体,因为它主要处理以相同方式表示的数据。

搭建舞台 (Setting the stage)

Before getting to the variations, I sorted out some basics for handling the 12 note musical system. The first thing I did is assign my tone row to a variable, so I don’t have to keep repeating all 12 numbers every time I reference it. APL uses this assignment operator: ←

在介绍变体之前,我整理了一些处理12音符音乐系统的基础知识。 我做的第一件事是将音调行分配给一个变量,因此我不必每次引用它时都重复所有12个数字。 APL使用此赋值运算符:←

apl code: “ROW←0 1 5 11 10 6 2 3 7 9 8 4”

The next thing I did was handle the modular arithmetic, where the numbers loop back to 0. There is no “12”, because that would be another “A”, which is 0, so 11 + 1 = 0, 10 + 6 = 4, etc… Another way of saying that is this number system is “modulus 12.” Similar to a remainder**, APL calls it the residue and uses the | operator. So that 12 | 16 returns 4. You can also do that with an array, like this:

我要做的下一件事是处理模块化算术 ,其中数字循环回到0。没有“ 12”,因为那将是另一个“ A”,即0,所以11 +1 = 0、10 + 6 = 4,等等。另一种说法是该数字系统是“模12”。 类似于余数**,APL将其称为残数并使用|。 操作员。 这样12 | 16返回4。您也可以使用数组来执行此操作,如下所示:

apl code: “12 | 0 13 17 71 34 30 134 51 7 45 20 124” returns “0 1 5 11 10 6 2 3 7 9 8 4”

The operation will be applied to each member of the array. This is a feature of the language and works for all APL operations. Which is neat, because most languages I know need a map function to do the same.

该操作将应用于数组的每个成员。 这是语言的功能,适用于所有APL操作。 这很整洁,因为我知道的大多数语言都需要一个map函数来执行相同的操作。

The above example returns the tone row we started with. But if you don’t want to manually compare the two, APL uses = to check equality:

上面的示例返回我们开始的音调行。 但是,如果您不想手动比较两者,则APL使用=检查相等性:

APL code: “ROW = 12 | 0 13 17 71 34 30 134 51 7 45 20 124” returns “1 1 1 1 1 1 1 1 1 1 1 1”

APL运营商进行12音操作 (APL Operators Doing 12-Tone Operations)

In serial music theory, the basic variations of the tone row you learn are retrograde (backwards), inversion (flipped), retrograde inversion (both of those), and transpositions (everything +/- the same).

在串行音乐理论中,您学到的音行的基本变化是逆行(向后),倒置(翻转),逆行倒置(两者)和移调(+/-都一样)。

retrograde — APL has the “reverse” operator: ⌽ It does what you might expect.

逆行 — APL具有“反向”运算符:⌽它可以实现您所期望的。

apl code: “⌽ ROW” returns “4 8 9 7 3 2 6 10 11 5 1 0”

inversion

倒置

Musical inversion means you travel in the opposite direction, but by the same amount from one number to the next. Instead of starting by going up 1, then up 4, we go down one (which would be 11) then down 4. To invert a 12 tone row, subtract each element from 12. And also apply the residue operator (on the left — using the right-to-left order of operations).

音乐倒置意味着您朝着相反的方向前进,但是从一个数字到另一个数字的方向相同。 而不是先上升1,然后上升4,我们先下降一个(将是11)然后下降4。要反转12个音调的行,请从12中减去每个元素。还要应用残差运算符(在左侧-使用从右到左的操作顺序)。

apl code: “12 | 12 — ROW” returns “0 11 7 1 2 6 10 9 5 3 4 8”

retrograde inversion — Combines those two.

逆行反转 -结合这两个。

apl code: “12 | ⌽ 12 — ROW” returns “8 4 3 5 9 10 6 2 1 7 11 0”

transposition — Add (or subtract) the same number across all 12 notes.

换位 —在所有12个音符中加(或减)相同的数字。

apl code: “12 | ROW + 5” returns “5 6 10 4 3 11 7 8 0 2 1 9”

矩阵 (The Matrix)

From these variations, you can combine them, to fit all versions of the tone row together in one 12 x 12 matrix.

从这些变体中,您可以将它们组合在一起,以将一个音色行的所有版本组合成一个12 x 12矩阵。

The idea of organizing this into a 12 tone matrix was developed by Arnold Schoenberg, who is often given credit for inventing the 12-tone system. It combines all these forms of the row — 48 altogether — in one simple chart. Each direction is a different form of the tone row, and the rows or columns running in that direction show the different transpositions of that form.

将其组织成12音矩阵的想法是由Arnold Schoenberg提出的,他经常因发明12音系统而受到赞誉。 它在一张简单的图表中将所有这些形式的行(总共48个)组合在一起。 每个方向都是音调行的不同形式,并且在该方向上延伸的行或列显示了该形式的不同换位。

The rows, running left to right, simply list all 12 transpositions of the tone row. And those rows of transpositions (from top to bottom) go in the order of the inversion of the row. So to create this, our APL program could take each number in the inversion, and add a new row to the matrix that transposes the original tone row by that number.

从左到右排列的行仅列出了音色行的所有12个变调。 那些换位行(从上到下)按该行倒置的顺序排列。 因此,为了创建此代码,我们的APL程序可以将求反时的每个数字都添加到矩阵中,并将新行添加到该矩阵中,从而将原始音调行按该数字进行转置。

outer productAPL has a combination of symbols that will do this logic. . is the Product operator, and ∘ is the Compose operator. By adding the compose operator before the product, and combine that with ‘x’, you get the expression to calculate the Outer Product: ∘.x Outer product is the same logic I described in the last paragraph, except it multiplies (using the ‘x’) instead of transposes. I replaced the multiplication with addition (∘.+), and it works as I hoped it would.

外部产品 APL具有将执行此逻辑的符号组合。 。 是Product运算符,∘是Compose运算符。 通过在产品前添加compose运算符,然后将其与'x'组合,您将获得表达式以计算外部乘积 :∘.x外部乘积与我在上一段中描述的逻辑相同,除了它乘以(使用' x')而不是转置。 我用加法(∘。+)代替了乘法,它按我希望的那样工作。

We use it like this: X ∘.+ Y

我们这样使用它:X∘。+ Y

We will want to take each element of the inversion, and apply transposition to the prime form:

我们将要取反演的每个元素,并将换位应用于素数形式:

apl code: (12 — ROW) ∘.+ ROW

I use parentheses here, so that the result of 12 — ROW counts as the X, instead of just ROW.

我在这里使用括号,以便将12的结果-ROW计为X,而不仅仅是ROW。

And finally, with the residue operator:

最后,使用残差运算符:

apl code: 12 | (12 — ROW) ∘.+ ROW

And there you have it. A few short lines of code in APL to assist in planning or expanding a musical idea using serial music techniques.

那里有。 APL中的几行简短代码可帮助您计划或扩展使用串行音乐技术的音乐创意。

代码摘要: (Summary of Code:)

retrograde . . . . . . . . . . ⌽ ROWinversion . . . . . . . . . . . 12 | 12 — ROWretrograde inversion . 12 | ⌽ 12 — ROWtransposition . . . . . . . 12 | ROW + 5matrix . . . . . . . . . . . . . 12 | (12 — ROW) ∘.+ ROW

逆行。 ⌽ROW 反演。 12 | 12-ROW 逆行反转 。 12 | ⌽12-ROW 换位。 12 | ROW + 5 矩阵。 12 | (12-行)∘。+行

This barely scratches the surface of APL, but is a good overall introduction and demonstrates how easy it is to deal with multi-dimensional arrays. The result of this simple equation provides the composer with 48 versions of the original tone row to work with. There’s a lot of information presented in a small space, allowing one to view it all at the same time.

这几乎没有触及APL的表面,但是是一个很好的整体介绍,并演示了处理多维数组有多么容易。 这个简单方程式的结果为作曲家提供了48种原始音调行供使用。 在一个很小的空间中显示了很多信息,使人们可以同时查看所有信息。

In my limited experience — having learned enough to do what I’ve shown here, and having dived a little deeper while writing this — I think this is a wonderful language. You might need a pretty specific set of requirements for APL to be the best choice for your project. There are many other languages and libraries that allow for similar manipulation of arrays and matrices without having to learn this new notation. But I really enjoy seeing code expressed as simple mathematical formulas, and I’m looking forward to trying more advanced things with it.

以我有限的经验-学到足够的知识去做我在这里所展示的内容,并且在编写本文时更深入地学习了-我认为这是一门很棒的语言。 您可能需要一套非常具体的APL要求,使其成为您项目的最佳选择。 还有许多其他语言和库允许对数组和矩阵进行类似的操作,而无需学习这种新的表示法。 但是我真的很高兴看到以简单的数学公式表示的代码,并且我期待着使用它来尝试更高级的东西。

— —

— —

*This is a gross oversimplification. If you are interested in further details about serialism, see links to more resources below.

*这太过简单了。 如果您对有关序列化的更多详细信息感兴趣,请参见下面更多资源的链接。

**Remainder is not actually the same as modulus — but for the case of positive numbers, they are functionally equivalent.

**余数实际上与模数不一样,但是对于正数,它们在功能上是等效的。

Links and resources:APL Introductory video: https://youtu.be/_DTpQ4Kk2wAAPL website: https://tryapl.orgAPL’s terseness explained/defended: https://news.ycombinator.com/item?id=13569516

链接和资源: APL入门视频: https ://youtu.be/_DTpQ4Kk2wA APL网站: https ://tryapl.org APL的简洁性得到了说明/捍卫: https ://news.ycombinator.com/item?id = 13569516

Twelve Tone basics: http://openmusictheory.com/twelveToneBasics.htmlU of Puget Sound Serialism: http://musictheory.pugetsound.edu/mt21c/Serialism.html

十二音基础知识: http ://openmusictheory.com/twelveToneBasics.html普吉特海湾音序主义: http ://musictheory.pugetsound.edu/mt21c/Serialism.html

翻译自: https://medium.com/@mike_88107/my-musical-introduction-to-apl-80efa80655de

resful apl

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值