1- use crate :: { handles:: * , utils:: * , XSynth_StreamParams } ;
1+ use crate :: { handles:: * , utils:: * , XSynth_ByteRange , XSynth_StreamParams } ;
22use xsynth_core:: {
33 channel:: { ChannelConfigEvent , ChannelEvent , ChannelInitOptions } ,
44 channel_group:: SynthEvent ,
@@ -17,14 +17,14 @@ use xsynth_realtime::{RealtimeSynth, XSynthRealtimeConfig};
1717/// usually causing clicking but improving performance.
1818/// - render_window_ms: The length of the buffer reader in ms
1919/// - ignore_range: A range of velocities that will not be played
20- /// LOBYTE = start (0-127), HIBYTE = end (start-127 )
20+ /// (see XSynth_ByteRange )
2121#[ repr( C ) ]
2222pub struct XSynth_RealtimeConfig {
2323 pub channels : u32 ,
2424 pub multithreading : i32 ,
2525 pub fade_out_killing : bool ,
2626 pub render_window_ms : f64 ,
27- pub ignore_range : u16 ,
27+ pub ignore_range : XSynth_ByteRange ,
2828}
2929
3030/// Generates the default values for the XSynth_RealtimeConfig struct
@@ -41,7 +41,7 @@ pub extern "C" fn XSynth_GenDefault_RealtimeConfig() -> XSynth_RealtimeConfig {
4141 multithreading : -1 ,
4242 fade_out_killing : false ,
4343 render_window_ms : 10.0 ,
44- ignore_range : 0 ,
44+ ignore_range : XSynth_ByteRange { start : 0 , end : 0 } ,
4545 }
4646}
4747
@@ -72,18 +72,12 @@ pub extern "C" fn XSynth_Realtime_Create(config: XSynth_RealtimeConfig) -> XSynt
7272 fade_out_killing : config. fade_out_killing ,
7373 } ;
7474
75- let ignore_range = {
76- let low = ( config. ignore_range & 255 ) as u8 ;
77- let high = ( config. ignore_range >> 8 ) as u8 ;
78- low..=high
79- } ;
80-
8175 let options = XSynthRealtimeConfig {
8276 channel_init_options,
8377 render_window_ms : config. render_window_ms ,
8478 format : convert_synth_format ( config. channels ) ,
8579 multithreading : convert_threadcount ( config. multithreading ) ,
86- ignore_range,
80+ ignore_range : config . ignore_range . start ..=config . ignore_range . end ,
8781 } ;
8882
8983 let new = RealtimeSynth :: open_with_default_output ( options) ;
@@ -169,6 +163,32 @@ pub extern "C" fn XSynth_Realtime_SendConfigEventAll(
169163 }
170164}
171165
166+ /// Sets the length of the buffer reader to the desired value in ms.
167+ ///
168+ /// --Parameters--
169+ /// - handle: The handle of the realtime synthesizer instance
170+ /// - render_window_ms: The length of the buffer reader in ms
171+ #[ no_mangle]
172+ pub extern "C" fn XSynth_Realtime_SetBuffer ( handle : XSynth_RealtimeSynth , render_window_ms : f64 ) {
173+ handle. as_ref ( ) . set_buffer ( render_window_ms) ;
174+ }
175+
176+ /// Sets the range of velocities that will be ignored.
177+ ///
178+ /// --Parameters--
179+ /// - handle: The handle of the realtime synthesizer instance
180+ /// - ignore_range: The range. LOBYTE = start (0-127), HIBYTE = end (start-127)
181+ #[ no_mangle]
182+ pub extern "C" fn XSynth_Realtime_SetIgnoreRange (
183+ handle : XSynth_RealtimeSynth ,
184+ ignore_range : XSynth_ByteRange ,
185+ ) {
186+ handle
187+ . as_mut ( )
188+ . get_sender_mut ( )
189+ . set_ignore_range ( ignore_range. start ..=ignore_range. end ) ;
190+ }
191+
172192/// Sets a list of soundfonts to be used in the specified realtime synth
173193/// instance. To load a new soundfont, see the XSynth_Soundfont_LoadNew
174194/// function.
@@ -248,7 +268,7 @@ pub extern "C" fn XSynth_Realtime_GetStats(handle: XSynth_RealtimeSynth) -> XSyn
248268/// - handle: The handle of the realtime synthesizer instance
249269#[ no_mangle]
250270pub extern "C" fn XSynth_Realtime_Reset ( handle : XSynth_RealtimeSynth ) {
251- handle. as_ref ( ) . get_senders ( ) . reset_synth ( ) ;
271+ handle. as_mut ( ) . get_sender_mut ( ) . reset_synth ( ) ;
252272}
253273
254274/// Drops the specified realtime synth instance.
0 commit comments