# Guqin open-string samples (public/audio/guqin)

## Source
- **Title:** Guqin-open-strings.wav
- **Author:** RafaelCaro — https://freesound.org/people/RafaelCaro/
- **Page:** https://freesound.org/people/RafaelCaro/sounds/176266/
- **License:** Creative Commons Attribution 4.0 International (CC BY 4.0) — https://creativecommons.org/licenses/by/4.0/

## Attribution (required by CC BY 4.0)
> Guqin open-string samples from "Guqin-open-strings.wav" by RafaelCaro ([Freesound #176266](https://freesound.org/people/RafaelCaro/sounds/176266/)), used under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Changes: sliced into single strings, ring extended, shortened, transposed in the player; see below.

中文：古琴空弦采样取自 RafaelCaro 的录音 "Guqin-open-strings.wav"（[Freesound #176266](https://freesound.org/people/RafaelCaro/sounds/176266/)），依 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 许可使用。本站对录音做了切片、延长余音、截短，并在播放时移调；详见下文。

## Changes made (CC BY 4.0 §3(a)(1)(B): indicate modifications)

### A. Offline, once — how the files here were made
The input is the public Freesound HQ preview (MP3) of the recording; the original WAV needs a Freesound login and was not used.
1. **Decode:** mono, 44.1 kHz.
2. **Slice:** cut into 7 single open-string notes (C D F G A c d) at the detected onsets; 3 ms fade-in on each slice. Each note's f0 is measured from its harmonics (as recorded, ≈ 12-TET, string 1 ≈ 65.27 Hz; listed in `bank.json`).
3. **Extended decay:** the recorded ring is only ~0.8–1.5 s, so the tail of each slice is replaced by an additive continuation fitted on that slice (up to 48 partials below 6 kHz: frequency, amplitude, phase and exponential decay per partial), cross-faded over 0.15 s. Partials below 3.5 × f0 keep a decay time (T60) of at least 3 s; higher partials get a shorter cap that falls with frequency. Each note is peak-normalised on its first 0.3 s.
4. **Truncation:** cut to 5.0 s (hard cut at 5 s; no extra fade in the file).
5. **Mono encode:** MP3 (mono, 44.1 kHz, 48 kbps CBR) and Ogg Vorbis (mono, 44.1 kHz) for the web player.

### B. In the browser, at every play (`src/lib/dapu-sampled.ts`)
6. **Transposition (playbackRate-style):** each note uses its own open string (散音) or the nearest open-string sample (按音 / 泛音). It is read at rate = target pitch ÷ sample f0, the same ratio as a Web Audio `playbackRate`, applied by linear-interpolation resampling in JavaScript. This retunes to 正调 · 纯律 (string 1 = C2 = 65.406 Hz). 上 / 下 slides change that rate along a 0.28 s S-curve.
7. **Light low-pass on stopped notes (按音):** a one-pole 2.4 kHz low-pass mixed 65 % filtered / 35 % dry, a softened 6 ms attack, and gain × 0.85. Open strings (散音) and harmonics (泛音) are not filtered.
8. **Mixing:** 撮 (two-string) notes are staggered by 18 ms by default (the listener can set 0–80 ms on the page; the same value is used by every voice) and scaled × 0.8. Each note gets a fixed pseudo-random level within ±1 dB (seeded, so it is the same on every play) and a 90 ms fade-out where it stops. The mix is normalised to a peak of 0.9.
9. **Optional reverb — only in the "采样 + 混响 / Sampled + reverb" voice:** a synthetic room, not a recorded one. The impulse response is seeded white noise under an exponential decay (RT60 1.6 s, 1.84 s long) after an 18 ms pre-delay, plus four early reflections at 11 / 19 / 27 / 41 ms (gains 0.45 / 0.32 / 0.28 / 0.20), energy-normalised. It is convolved with the mix (every tap in the first 80 ms, then every 64th tap × 8) and blended 82 % dry / 18 % wet, with a ×2.5 gain on the wet signal (output = 0.82 · dry + 0.18 · 2.5 · wet). If the result peaks above 0.95 it is scaled to 0.9. The plain "采样 / Sampled" voice has no reverb.

## Not included
The full Freesound preview, concert phrases, or any other Freesound pack content are **not** shipped.
