Skip to content

Commit

Permalink
export sound channel count matched to sound flags. fix bigfile_extens…
Browse files Browse the repository at this point in the history
…ions const
  • Loading branch information
pizzart committed Oct 10, 2023
1 parent 2aaf08d commit f910397
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
10 changes: 8 additions & 2 deletions bff-gui/src-tauri/src/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ impl Export for Box<Sound> {
match **self {
Sound::SoundV1_291_03_06PC(ref sound) => {
let spec = hound::WavSpec {
channels: 1,
channels: match sound.body.flags.stereo().value() {
1 => 2,
_ => 1,
},
sample_rate: sound.body.sample_rate,
bits_per_sample: 16,
sample_format: hound::SampleFormat::Int,
Expand All @@ -30,7 +33,10 @@ impl Export for Box<Sound> {
}
Sound::SoundV1_381_67_09PC(ref sound) => {
let spec = hound::WavSpec {
channels: 1,
channels: match sound.link_header.flags.stereo().value() {
1 => 2,
_ => 1,
},
sample_rate: sound.link_header.sample_rate,
bits_per_sample: 16,
sample_format: hound::SampleFormat::Int,
Expand Down
3 changes: 0 additions & 3 deletions bff-gui/src/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { invoke } from "@tauri-apps/api";
import {
MeshBasicMaterial,
MeshNormalMaterial,
Expand All @@ -20,5 +19,3 @@ export const EXTENSION_DESCRIPTIONS: Map<string, string> = new Map([
export const DEFAULT_MAT = new MeshStandardMaterial();
export const NORMAL_MAT = new MeshNormalMaterial();
export const WIREFRAME_MAT = new MeshBasicMaterial({ wireframe: true });

export const BIGFILE_EXTENSIONS: string[] = await invoke("get_extensions");
11 changes: 7 additions & 4 deletions bff-gui/src/functions/bigfile.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { message, open } from "@tauri-apps/api/dialog";
import { BIGFILE_EXTENSIONS } from "../constants/constants";
import { invoke } from "@tauri-apps/api";
import { BigFileData, ResourcePreview } from "../types/types";

export async function selectBigfile(
setPreviewObject: React.Dispatch<React.SetStateAction<ResourcePreview | null>>,
setPreviewObject: React.Dispatch<
React.SetStateAction<ResourcePreview | null>
>,
setBigfile: React.Dispatch<React.SetStateAction<BigFileData>>
) {
open({
multiple: false,
filters: [
{
name: "BigFile",
extensions: BIGFILE_EXTENSIONS,
extensions: await invoke("get_extensions"),
},
],
}).then((path) => {
Expand All @@ -23,7 +24,9 @@ export async function selectBigfile(

export async function openBigfile(
path: string,
setPreviewObject: React.Dispatch<React.SetStateAction<ResourcePreview | null>>,
setPreviewObject: React.Dispatch<
React.SetStateAction<ResourcePreview | null>
>,
setBigfile: React.Dispatch<React.SetStateAction<BigFileData>>
) {
setPreviewObject(null);
Expand Down
6 changes: 3 additions & 3 deletions bff/src/class/sound/v1_291_03_06_pc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use crate::class::trivial_class::TrivialClass;

#[bitsize(16)]
#[derive(DebugBits, BinRead, SerializeBits, BinWrite, DeserializeBits)]
struct SoundFlags {
pub struct SoundFlags {
paused: u1,
looping: u1,
stereo: u1,
pub stereo: u1,
padding: u13,
}

Expand All @@ -18,7 +18,7 @@ struct SoundFlags {
pub struct SoundBodyV1_291_03_06PC {
pub sample_rate: u32,
data_size: u32,
flags: SoundFlags,
pub flags: SoundFlags,
#[br(count = data_size / 2)]
#[serde(skip_serializing)]
pub data: Vec<i16>,
Expand Down
6 changes: 3 additions & 3 deletions bff/src/class/sound/v1_381_67_09_pc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use crate::names::Name;

#[bitsize(16)]
#[derive(BinRead, DebugBits, SerializeBits, BinWrite, DeserializeBits)]
struct SoundFlags {
pub struct SoundFlags {
paused: u1,
looping: u1,
stereo: u1,
pub stereo: u1,
padding: u13,
}

Expand All @@ -19,7 +19,7 @@ pub struct LinkHeader {
link_name: Name,
pub sample_rate: u32,
sound_data_size: u32,
flags: SoundFlags,
pub flags: SoundFlags,
}

#[derive(BinRead, Debug, Serialize, BinWrite, Deserialize)]
Expand Down

0 comments on commit f910397

Please sign in to comment.