2 stable releases
1.0.1 | Aug 30, 2022 |
---|
#1070 in Audio
2.5MB
424 lines
Contains (WOFF font, 680KB) docs/NanumBarunGothic.ttf.woff, (WOFF font, 400KB) docs/NanumBarunGothic.ttf.woff2, (WOFF font, 190KB) docs/FiraSans-Medium.woff, (WOFF font, 135KB) docs/FiraSans-Medium.woff2, (WOFF font, 185KB) docs/FiraSans-Regular.woff, (WOFF font, 130KB) docs/FiraSans-Regular.woff2 and 12 more.
LSynth is a virtual soundchip designed to be the APU of the LIKO-12 fantasy console.
Go nuts.
lib.rs
:
This library is for generating L-Synth audio streams.
Here is an example of the basic setup of the LSynth chip. Whatever library you are using to play this audio should provide an audio buffer for L-Synth to populate, represented here by the buffer
parameter of audio_sample_request
use lsynth::*;
let mut chip = ChipState::new(4, ChipParameters::new(44_100, 0.5, 120.0));
chip.send_command(Command::SetAmplitude(0.5), 0);
chip.send_command(Command::SetFrequency(110.0), 0);
let mut frequency = 110.0;
let mut beat = 0;
let mut request_callback = move |chip: &mut ChipState| {
beat += 1;
while beat >= 4 {
frequency += 110.0;
chip.send_command(Command::SetFrequency(frequency), 0);
beat -= 4;
}
};
let mut audio_sample_request = move |buffer: &mut [f32]| {
let mut sample_index = 0;
while sample_index < buffer.len() {
let generated_data = chip.generate(&mut buffer[sample_index..]).unwrap();
sample_index += generated_data.generated;
assert!(generated_data.generated != 0);
if generated_data.remaining_samples == 0 { request_callback(&mut chip); }
}
};
#