-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added bnvib #196
Added bnvib #196
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from enum import Enum | ||
|
||
import construct | ||
from construct.core import ( | ||
Byte, | ||
Const, | ||
Construct, | ||
If, | ||
Int16ul, | ||
Int32ul, | ||
PrefixedArray, | ||
Struct, | ||
) | ||
|
||
from mercury_engine_data_structures.adapters.enum_adapter import EnumAdapter | ||
from mercury_engine_data_structures.formats.base_resource import BaseResource | ||
from mercury_engine_data_structures.game_check import Game | ||
|
||
|
||
class VibrationType(Enum): | ||
NORMAL = 4 | ||
LOOP = 12 | ||
LOOPWAIT = 16 | ||
|
||
BNVIB = Struct( | ||
"vibration_type" / EnumAdapter(VibrationType, Int32ul), | ||
"_magic" / Const(3, Int16ul), | ||
"sample_rate" / Int16ul, | ||
"loop_start" / If(construct.this.vibration_type != VibrationType.NORMAL, Int32ul), | ||
"loop_end" / If(construct.this.vibration_type != VibrationType.NORMAL, Int32ul), | ||
"loop_wait" / If(construct.this.vibration_type == VibrationType.LOOPWAIT, Int32ul), | ||
"data" / PrefixedArray(Int32ul, Byte) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually looking at the documentation more closely: "The size of a sample is 4 bytes." |
||
) | ||
|
||
class Bnvib(BaseResource): | ||
@classmethod | ||
def construct_class(cls, target_game: Game) -> Construct: | ||
return BNVIB |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
from tests.test_lib import parse_build_compare_editor | ||
|
||
from mercury_engine_data_structures import dread_data | ||
from mercury_engine_data_structures.formats.bnvib import Bnvib | ||
|
||
|
||
@pytest.mark.parametrize("bnvib_path", dread_data.all_files_ending_with(".bnvib")) | ||
def test_bgsnds(dread_file_tree, bnvib_path): | ||
parse_build_compare_editor(Bnvib, dread_file_tree, bnvib_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to have a link to the switchbrew wiki page here.