mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: fix ./v -W -Wfatal-errors build-examples
, run vfmt
This commit is contained in:
parent
7c7df37abb
commit
12897d1e2b
@ -48,16 +48,16 @@ fn audio_player_callback(buffer &f32, num_frames int, num_channels int, mut p Pl
|
||||
p.finished = true
|
||||
return
|
||||
}
|
||||
unsafe {C.memcpy(buffer, &p.samples[p.pos], nsamples * int(sizeof(f32)))}
|
||||
unsafe { C.memcpy(buffer, &p.samples[p.pos], nsamples * int(sizeof(f32))) }
|
||||
p.pos += nsamples
|
||||
}
|
||||
|
||||
fn (mut p Player) init() {
|
||||
audio.setup({
|
||||
audio.setup(
|
||||
num_channels: 2
|
||||
stream_userdata_cb: audio_player_callback
|
||||
user_data: p
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
fn (mut p Player) stop() {
|
||||
@ -104,15 +104,15 @@ struct RIFFChunkHeader {
|
||||
}
|
||||
|
||||
struct RIFFFormat {
|
||||
format_tag u16 // PCM = 1; Values other than 1 indicate some form of compression.
|
||||
nchannels u16 // Nc ; 1 = mono ; 2 = stereo
|
||||
sample_rate u32 // F
|
||||
avg_bytes_per_second u32 // F * M*Nc
|
||||
nblock_align u16 // M*Nc
|
||||
bits_per_sample u16 // 8 * M
|
||||
cbsize u16 // Size of the extension: 22
|
||||
valid_bits_per_sample u16 // at most 8*M
|
||||
channel_mask u32 // Speaker position mask
|
||||
format_tag u16 // PCM = 1; Values other than 1 indicate some form of compression.
|
||||
nchannels u16 // Nc ; 1 = mono ; 2 = stereo
|
||||
sample_rate u32 // F
|
||||
avg_bytes_per_second u32 // F * M*Nc
|
||||
nblock_align u16 // M*Nc
|
||||
bits_per_sample u16 // 8 * M
|
||||
cbsize u16 // Size of the extension: 22
|
||||
valid_bits_per_sample u16 // at most 8*M
|
||||
channel_mask u32 // Speaker position mask
|
||||
sub_format [16]byte // GUID
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ fn read_wav_file_samples(fpath string) ?[]f32 {
|
||||
break
|
||||
}
|
||||
//
|
||||
ch := &RIFFChunkHeader(unsafe {pbytes + offset})
|
||||
ch := &RIFFChunkHeader(unsafe { pbytes + offset })
|
||||
offset += 8 + ch.chunk_size
|
||||
// eprintln('ch: $ch')
|
||||
// eprintln('p: $pbytes | offset: $offset | bytes.len: $bytes.len')
|
||||
@ -155,7 +155,7 @@ fn read_wav_file_samples(fpath string) ?[]f32 {
|
||||
//
|
||||
if ch.chunk_type == [byte(`f`), `m`, `t`, ` `]! {
|
||||
// eprintln('`fmt ` chunk')
|
||||
rf = &RIFFFormat(&ch.chunk_data)
|
||||
rf = unsafe { &RIFFFormat(&ch.chunk_data) }
|
||||
// eprintln('fmt riff format: $rf')
|
||||
if rf.format_tag != 1 {
|
||||
return error('only PCM encoded WAVs are supported')
|
||||
@ -180,7 +180,7 @@ fn read_wav_file_samples(fpath string) ?[]f32 {
|
||||
for c := 0; c < rf.nchannels; c++ {
|
||||
mut x := f32(0.0)
|
||||
mut step := 0
|
||||
ppos := unsafe {dp + doffset}
|
||||
ppos := unsafe { dp + doffset }
|
||||
if rf.bits_per_sample == 8 {
|
||||
d8 := byteptr(ppos)
|
||||
x = (f32(*d8) - 128) / 128.0
|
||||
|
Loading…
Reference in New Issue
Block a user