This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
api:note:zh [2022/08/11 09:18] fight_xing created |
api:note:zh [2023/11/29 14:25] (current) hfsr [Note(音符) API] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Note API | + | Note(音符) API |
======= | ======= | ||
- | + | Note(音符) API提供了将音符转换为它们各自的MIDI编码和/或频率(单位为赫兹)的功能,以及一些其他功能。此API常与`computer.beep`以及原版的音符盒(需安装OpenComponents模组)配合使用。 | |
- | **本篇文章的部分/全部内容还没有进行翻译。** | + | |
- | + | ||
- | The Note API provides functionality to convert music notes into their respective MIDI code and/or their frequency in Hertz, among other things. It it used in combination with computer.beep and note blocks (using OpenComponents). | + | |
- `note.midi(n: number or string): number` | - `note.midi(n: number or string): number` | ||
- | Converts a note in string form (e.g. A#4 or Gb3, see below) or a given frequency into the respective MIDI code | + | 将字符串格式的音符(如 A#4 或 Gb3,查看下表)或给出的频率转换为MIDI编码。 |
+ | \\ | ||
- `note.freq(n: number or string): number` | - `note.freq(n: number or string): number` | ||
- | Converts a note in string form (e.g. A#4) or a given MIDI code into the respective frequency | + | 将字符串格式的音符(如 A#4)或给出的MIDI编码转换为频率。 |
+ | \\ | ||
- `note.name(n: number): string` | - `note.name(n: number): string` | ||
- | Converts a MIDI value back into a string; if you have a frequency to convert, just use `note.name(note.midi(frequency))` | + | 将MIDI编码转换回字符串。如果你需要转换频率,请用`note.name(note.midi(frequency))`。 |
+ | \\ | ||
- `note.ticks(n: number): number` | - `note.ticks(n: number): number` | ||
- | Converts note block ticks (0-24) into MIDI code (34-58, respectively) and vice-versa. Useful for use with Note Blocks and OpenComponents | + | 将音符盒的音高(0-24)转换为MIDI编码(分别对应34-58),或者反过来。在与音符盒以及OpenComponents配合使用时很有帮助。 |
+ | \\ | ||
- `note.play(tone: string or number,duration: number)` | - `note.play(tone: string or number,duration: number)` | ||
- | Plays a note from a string or MIDI code via computer.beep with the specified duration | + | 通过`computer.beep`演奏字符串或MIDI编码对应的音符,时长为`duration`参数。 |
- | ###Available notes | + | ###可用音符 |
- | The available string names, their respective MIDI code and their frequency are shown here: | + | 可用的字符串名称、它们对应的MIDI编码和频率如下表所示: |
- | ^Name^MIDI code^Frequency^ | + | ^名称^MIDI编码^频率^ |
|A0|21|27.5000| | |A0|21|27.5000| | ||
|A#0/Bb0|22|29.1352| | |A#0/Bb0|22|29.1352| |