mirror of
https://github.com/ScrelliCopter/VGM-Tools
synced 2025-02-21 04:09:25 +11:00
wavetable stuff
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
# riffwriter.py -- Generic RIFF writing framework
|
||||
# (C) 2023 a dinosaur (zlib)
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import BinaryIO, List
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
# wavesampler.py -- Support for the non-standard "Sampler" WAVE chunk
|
||||
# (C) 2023 a dinosaur (zlib)
|
||||
|
||||
import struct
|
||||
from enum import Enum
|
||||
from riffwriter import AbstractRiffChunk
|
||||
from typing import BinaryIO, List
|
||||
from common.riffwriter import AbstractRiffChunk
|
||||
|
||||
|
||||
class WaveSamplerSMPTEOffset:
|
||||
|
||||
18
common/waveserum.py
Normal file
18
common/waveserum.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# waveserum.py -- Serum comment chunk support
|
||||
# (C) 2023 a dinosaur (zlib)
|
||||
|
||||
from enum import Enum
|
||||
from common.wavewriter import WaveCommentChunk
|
||||
|
||||
|
||||
class SerumWavetableInterpolation(Enum):
|
||||
NONE = 0
|
||||
LINEAR_XFADE = 1
|
||||
SPECTRAL_MORPH = 2
|
||||
|
||||
|
||||
class WaveSerumCommentChunk(WaveCommentChunk):
|
||||
def __init__(self, size: int, mode: SerumWavetableInterpolation, factory=False):
|
||||
comment = f"<!>{size: <4} {mode.value}{'1' if factory else '0'}000000"
|
||||
comment += " wavetable (www.xferrecords.com)"
|
||||
super().__init__(comment.encode("ascii"))
|
||||
@@ -1,8 +1,11 @@
|
||||
# wavewriter.py -- Extensible WAVE writing framework
|
||||
# (C) 2023 a dinosaur (zlib)
|
||||
|
||||
import struct
|
||||
from abc import abstractmethod
|
||||
from enum import Enum
|
||||
from typing import BinaryIO, List
|
||||
from riffwriter import RiffFile, AbstractRiffChunk
|
||||
from common.riffwriter import RiffFile, AbstractRiffChunk
|
||||
|
||||
|
||||
class WaveSampleFormat(Enum):
|
||||
@@ -46,6 +49,11 @@ class WaveAbstractFormatChunk(AbstractRiffChunk):
|
||||
self.bitdepth()))
|
||||
|
||||
|
||||
class WaveFile(RiffFile):
|
||||
def __init__(self, format: WaveAbstractFormatChunk, chunks: List[AbstractRiffChunk]):
|
||||
super().__init__(b"WAVE", [format] + chunks)
|
||||
|
||||
|
||||
class WavePcmFormatChunk(WaveAbstractFormatChunk):
|
||||
def sampleformat(self) -> WaveSampleFormat: return WaveSampleFormat.PCM
|
||||
|
||||
@@ -88,8 +96,3 @@ class WaveCommentChunk(AbstractRiffChunk):
|
||||
|
||||
def __init__(self, comment: bytes):
|
||||
self._comment = comment
|
||||
|
||||
|
||||
class WaveFile(RiffFile):
|
||||
def __init__(self, format: WaveAbstractFormatChunk, chunks: List[AbstractRiffChunk]):
|
||||
super().__init__(b"WAVE", [format] + chunks)
|
||||
|
||||
Reference in New Issue
Block a user