Class ElectronicArtsAudioCore
Provides methods for dealing with sounds in Electronic Arts' AudioCore format: the AudioVocals resources of The Sims 4 (a header, followed by its audio if the sound is held in memory) and their AudioEffects bodies (the audio of a streamed sound)
public static class ElectronicArtsAudioCore
- Inheritance
-
ElectronicArtsAudioCore
- Inherited Members
Remarks
The rebuilding of EALayer3 into MP3 is adapted from vgmstream (see Formats/Vgmstream/license.txt); unlike vgmstream, it lays the audio out at a constant bitrate with a bit reservoir and adds a gapless playback tag, so that ordinary MP3 decoders play it sample for sample as the game does
Methods
CreateFromMp3(ElectronicArtsAudioCoreMp3)
Makes a sound for The Sims 4 from the MP3s GetMp3(ReadOnlyMemory<byte>, ReadOnlyMemory<byte>) rebuilt from one, without re-encoding them, stored as the original was
public static ElectronicArtsAudioCoreSound CreateFromMp3(ElectronicArtsAudioCoreMp3 mp3)
Parameters
Returns
Exceptions
- InvalidDataException
An MP3 is malformed
- NotSupportedException
The sound is not one this can make
CreateFromMp3(IReadOnlyList<IReadOnlyList<ReadOnlyMemory<byte>>>, ElectronicArtsAudioCoreStorage, bool)
Makes a sound for The Sims 4 from MP3s, without re-encoding them
public static ElectronicArtsAudioCoreSound CreateFromMp3(IReadOnlyList<IReadOnlyList<ReadOnlyMemory<byte>>> segments, ElectronicArtsAudioCoreStorage storage, bool isLooping)
Parameters
segmentsIReadOnlyList<IReadOnlyList<ReadOnlyMemory<byte>>>The MP3s of the sound: one segment, or, for a sound that loops from somewhere other than its start, the part before the loop and the loop; each segment's MP3s are layers played together (all stereo, except that the last may be mono), with the same number of frames
storageElectronicArtsAudioCoreStorageWhere the game should find the audio
isLoopingboolWhether the sound loops (from its start, with one segment; from the start of the second segment, with two)
Returns
Exceptions
- ArgumentException
segmentsis empty, has more than two segments, has two withoutisLooping, or has a segment without MP3s- InvalidDataException
An MP3 is malformed, the MP3s disagree about their sample rate, layout or length, or the sound is too long for
storage- NotSupportedException
An MP3 is not MPEG-1 Layer III (32,000, 44,100 or 48,000 Hz), or
storageis Gigasample
CreateFromMp3(ReadOnlyMemory<byte>, ElectronicArtsAudioCoreStorage, bool)
Makes a sound for The Sims 4 from an MP3, without re-encoding it
public static ElectronicArtsAudioCoreSound CreateFromMp3(ReadOnlyMemory<byte> mp3Data, ElectronicArtsAudioCoreStorage storage, bool isLooping = false)
Parameters
mp3DataReadOnlyMemory<byte>The MP3: MPEG-1 Layer III (32,000, 44,100 or 48,000 Hz), mono or stereo, constant or variable bitrate (not free format)
storageElectronicArtsAudioCoreStorageWhere the game should find the audio: Memory (in the AudioVocals resource) or Stream (in an AudioEffects resource with the same instance)
isLoopingboolWhether the sound loops from its start
Returns
Remarks
The sound's length comes from the MP3's gapless playback tag (as LAME and the tools built on it write); an MP3 without one is taken to end where its last frame does. The game's sounds begin with 47 samples stored uncompressed, which this writes as silence, so the first millisecond of the MP3 is not heard.
Exceptions
- InvalidDataException
The MP3 is malformed, or its tag declares an encoder delay of less than 576 samples
- NotSupportedException
The MP3 is not MPEG-1 Layer III (32,000, 44,100 or 48,000 Hz), or is free format
GetMp3(ReadOnlyMemory<byte>, ReadOnlyMemory<byte>)
Rebuilds a sound encoded with ElectronicArtsLayer3Version1 as MP3, without re-encoding it
public static ElectronicArtsAudioCoreMp3 GetMp3(ReadOnlyMemory<byte> headerData, ReadOnlyMemory<byte> streamData = default)
Parameters
headerDataReadOnlyMemory<byte>The data of the sound's AudioVocals resource
streamDataReadOnlyMemory<byte>The data of the sound's AudioEffects resource, if the sound is streamed
Returns
Exceptions
- ArgumentException
The sound is streamed and
streamDatais empty- InvalidDataException
The header or the audio is malformed
- NotSupportedException
The sound uses another codec or another version of the header (The Sims 4's sounds are version 0), or is stored as a Gigasample