Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions neothesia-core/src/utils/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ pub fn default_sf2() -> Option<PathBuf> {
return Some(path);
}

// Development: workspace-root default.sf2 (debug builds only).
#[cfg(debug_assertions)]
if let Some(path) = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.map(|p| p.join("default.sf2"))
&& path.exists()
{
return Some(path);
}

let flatpak = PathBuf::from("/app/share/neothesia/default.sf2");
if flatpak.exists() {
Some(flatpak)
Expand Down
11 changes: 10 additions & 1 deletion neothesia/src/output_manager/synth_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::output_manager::OutputDescriptor;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use midi_file::midly::{self, num::u4};

const OUTPUT_BUFFER_FRAMES: u32 = 1024;

#[cfg(all(feature = "fluid-synth", not(feature = "oxi-synth")))]
const SAMPLES_SIZE: usize = 1410;

Expand All @@ -28,7 +30,14 @@ impl SynthBackend {
let config = device.default_output_config()?;
let sample_format = config.sample_format();

let stream_config: cpal::StreamConfig = config.into();
let buffer_size = match config.buffer_size() {
cpal::SupportedBufferSize::Range { min, max } => {
cpal::BufferSize::Fixed(OUTPUT_BUFFER_FRAMES.clamp(*min, *max))
}
cpal::SupportedBufferSize::Unknown => cpal::BufferSize::Default,
};
let mut stream_config: cpal::StreamConfig = config.into();
stream_config.buffer_size = buffer_size;

Ok(Self {
_host: host,
Expand Down
Loading