Merge pull request #308 from tidalcycles/pianoroll-freq-support

support freq in pianoroll
This commit is contained in:
Felix Roos 2022-12-15 21:23:22 +01:00 committed by GitHub
commit e6bbad84c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,11 +4,19 @@ Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/st
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Pattern, toMidi, getDrawContext } from './index.mjs';
import { Pattern, toMidi, getDrawContext, freqToMidi } from './index.mjs';
const scale = (normalized, min, max) => normalized * (max - min) + min;
const getValue = (e) => {
let value = typeof e.value === 'object' ? e.value.note ?? e.value.n : e.value;
let { value } = e;
if (typeof e.value !== 'object') {
value = { value };
}
let { note, n, freq } = value;
if (freq) {
note = freqToMidi(freq);
}
value = note ?? n ?? e.value;
if (typeof value === 'string') {
value = toMidi(value);
}