6 struct sample_spec default_sample_spec
= {
7 .format
= SAMPLE_S16NE
,
12 struct memblock
*silence(struct memblock
* b
, struct sample_spec
*spec
) {
15 memblock_assert_exclusive(b
);
17 switch (spec
->format
) {
32 memset(b
->data
, c
, b
->length
);
36 void add_clip(struct memchunk
*target
, struct memchunk
*chunk
, struct sample_spec
*spec
) {
39 assert(target
&& target
->memblock
&& chunk
&& chunk
->memblock
&& spec
);
40 assert(spec
->format
== SAMPLE_S16NE
);
41 assert((target
->length
& 1) == 0);
43 d
= target
->memblock
->data
+ target
->index
;
44 p
= chunk
->memblock
->data
+ chunk
->index
;
46 for (i
= 0; i
< target
->length
&& i
< chunk
->length
; i
++) {
47 int32_t r
= (int32_t) *d
+ (int32_t) *p
;
48 if (r
< -0x8000) r
= 0x8000;
49 if (r
> 0x7FFF) r
= 0x7FFF;
54 size_t sample_size(struct sample_spec
*spec
) {
58 switch (spec
->format
) {
73 return b
* spec
->channels
;
76 size_t bytes_per_second(struct sample_spec
*spec
) {
78 return spec
->rate
*sample_size(spec
);