mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-17 11:18:31 +01:00
Round .vs/svs pitch values
This commit is contained in:
parent
da0166f90d
commit
8ae4ea3000
@ -32,7 +32,7 @@ VGMSTREAM * init_vgmstream_svs(STREAMFILE *streamFile) {
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_SVS;
|
||||
vgmstream->sample_rate = (48000 * pitch) / 4096; /* music = ~44100, ambience = 48000 */
|
||||
vgmstream->sample_rate = round10((48000 * pitch) / 4096); /* music = ~44100, ambience = 48000 (rounding makes more sense but not sure) */
|
||||
vgmstream->num_samples = ps_bytes_to_samples(get_streamfile_size(streamFile) - start_offset, channel_count);
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile) * 28; /* frame count (0x10*ch) */
|
||||
|
@ -35,7 +35,7 @@ VGMSTREAM * init_vgmstream_vs_ffx(STREAMFILE *streamFile) {
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_VS_FFX;
|
||||
vgmstream->sample_rate = (48000 * pitch) / 4096; /* verified, needed for rare files */
|
||||
vgmstream->sample_rate = round10((48000 * pitch) / 4096); /* needed for rare files */
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_blocked_vs_ffx;
|
||||
|
||||
|
@ -67,6 +67,14 @@ static inline int clamp16(int32_t val) {
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline int round10(int val) {
|
||||
int round_val = val % 10;
|
||||
if (round_val < 5) /* half-down rounding */
|
||||
return val - round_val;
|
||||
else
|
||||
return val + (10 - round_val);
|
||||
}
|
||||
|
||||
/* return a file's extension (a pointer to the first character of the
|
||||
* extension in the original filename or the ending null byte if no extension */
|
||||
const char * filename_extension(const char * filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user