Skip to content

Commit cf2bff5

Browse files
committed
sokol.audio: fix doc comment examples
1 parent 50e2d03 commit cf2bff5

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

‎vlib/sokol/audio/audio.c.v‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,16 @@ $if linux {
3737
//
3838
// Do not write more data to the buffer than it is requesting, but you may write less. The buffer is initialized with
3939
// zeroes, so unwritten data will result in audio silence.
40-
// Example: unsafe { C.memcpy(buffer, &samples, samples.len * int(sizeof(f32))) }
41-
// Example: unsafe { mut b := buffer; for i, sample in samples { b[i] = sample } }
40+
// Example body: unsafe { C.memcpy(buffer, &samples, samples.len * int(sizeof(f32))) }
41+
// Example body: unsafe { mut b := buffer; for i, sample in samples { b[i] = sample } }
4242
pub type FNStreamingCB = fn (buffer &f32, num_frames int, num_channels int)
4343

4444
// callback function for `stream_userdata_cb` to use in `C.saudio_desc` when calling [audio.setup()](#setup)
45-
//
46-
// sokol callback functions run in a separate thread
47-
//
4845
// This function operates the same way as [[FNStreamingCB](#FNStreamingCB)] but it passes customizable `user_data` to the
4946
// callback. This is the method to use if your audio data is stored in a struct or array. Identify the
5047
// `user_data` when you call `audio.setup()` and that object will be passed to the callback as the last arg.
51-
// Example: mut soundbuffer := []f32
52-
// Example: soundbuffer << previously_parsed_wavfile_bytes
53-
// Example: audio.setup(stream_userdata_cb: mycallback, user_data: soundbuffer)
54-
// Example: fn mycallback(buffer &f32, num_frames int, num_channels int, mut sb []f32) { ... }
48+
// Note: Sokol's callback functions run in a separate thread.
49+
// Example: previously_parsed_wavfile_bytes := [f32(0),0,0,0]; mycallback := fn (buffer &f32, num_frames int, num_channels int, mut sb []f32) {}; mut soundbuffer := []f32{}; soundbuffer << previously_parsed_wavfile_bytes; audio.setup(stream_userdata_cb: mycallback, user_data: soundbuffer.data);
5550
pub type FnStreamingCBWithUserData = fn (buffer &f32, num_frames int, num_channels int, user_data voidptr)
5651

5752
pub fn (x FNStreamingCB) str() string {
@@ -195,7 +190,7 @@ pub fn push(frames &f32, num_frames int) int {
195190
}
196191

197192
// fclamp - helper function to 'clamp' a number to a certain range
198-
// Example: realsample := audio.fclamp(sample, -1.0, 1.0)
193+
// Example: sample := f32(3.14); realsample := audio.fclamp(sample, -1.0, 1.0); assert realsample == 1.0
199194
@[inline]
200195
pub fn fclamp(x f32, flo f32, fhi f32) f32 {
201196
if x > fhi {

0 commit comments

Comments
 (0)