Commit Graph

34 Commits

Author SHA1 Message Date
RoosterDragon
b313f47660 Implement Stream.Read(Span<byte>) overloads.
The default Stream implementation of this method has to rent an array so it can call the overload that accepts an array, and then copy the output over. This is because the array overload is required and the span overload was only added more recently.

We can avoid the overhead of this by implementing the span overload and working with the destination span directly. Do so for all classes we have that derive from Stream, and redirect their array overload to the span overload for code reuse.
2024-08-04 10:40:43 +01:00
RoosterDragon
5d91b678bb Use spans to improve performance in StreamExts.
Also avoid ReadBytes calls that allocate a buffer by either updating the stream position (if not interested in the bytes), by reusing an input buffer (if interested in the bytes), or using a stackalloc buffer to avoid the allocation (for small reads).
2023-11-10 10:25:39 +02:00
RoosterDragon
277699cbd5 Fix CA1822 2023-06-06 11:51:47 +03:00
RoosterDragon
ef04e2e1e8 Fix CA2019 2023-04-17 00:05:12 +02:00
RoosterDragon
bd2b3d9793 Fix IDE0074 2023-04-08 16:51:51 +03:00
IceReaper
4dd532f60e Implemented MP3 detection. 2023-04-03 20:05:52 +02:00
RoosterDragon
98c4eaca83 Fix IDE0032 2023-03-14 13:41:25 +02:00
abcdefg30
5bf7fe852c Remove the copyright year numbers 2023-01-11 11:58:54 +02:00
abcdefg30
6a31b1f9f3 Update the copyright header year 2022-05-28 00:35:10 -05:00
penev92
6fb228ddd1 Fixed Mp3Loader and OggLoader not resetting stream position 2022-01-09 18:40:32 +01:00
penev92
87b92b53a4 Reworked ISoundFormat.LengthInSeconds implementations 2022-01-09 18:40:32 +01:00
penev92
abea3a0f74 Fixed AudFormat and WavFormat implementations of ISoundFormat.LengthInSeconds
- Fixed a rounding issue in `WavReader.WaveLength()`.
- Fixed `AudReader.SoundLength()` not resetting the stream position.
- Fixed crashes caused by disposed streams because `LengthInSeconds` would try and calculate the length on the fly. It is now precalculated and cached (making it consistent across all 5 current `ISoundFormat` implementations).
- Fixed a crash in `AudReader.LoadSound()`'s `out Func<Stream> result` because that func would try and access the disposed stream's `Length` property. That works for `SegmentStream`, but not for `FileStream`.
- Fixed frameCount/soundLength label positioning in the AssetBrowser window to avoid text clipping .
2022-01-09 18:40:32 +01:00
Matthias Mailänder
b2f18ad0ad Add support for .ogg files. 2021-07-12 00:35:16 +02:00
Paul Chote
25c095619a Parse Mp3 length from metadata tags. 2021-07-07 15:20:47 +02:00
Matthias Mailänder
407372268d Add support for .mp3 files. 2021-07-07 15:20:47 +02:00
Andre Mohren
6810469634 Updated copyright years. 2021-06-29 18:33:21 -05:00
teinarss
4a1e4f3e16 Use expression body syntax 2021-03-07 13:00:52 +00:00
abcdefg30
23b3c237b7 Update the year numbers in all license headers to 2020 2020-01-05 17:00:34 +00:00
reaperrr
82be8d9990 Move AUD support to Mods.Cnc 2019-12-09 22:06:53 +01:00
reaperrr
65728bc032 Move VocLoader to Mods.D2k
While this is strictly speaking a D2 format, any
D2 mod is pretty much guaranteed to use Mods.D2k,
so this should be a good enough place to move it to.
2019-11-23 19:04:27 +01:00
Paul Chote
548de12e85 Add newlines after closing braces. 2019-06-08 13:20:14 +02:00
Paul Chote
ebd36891dc Switch other struct types to default(T). 2019-06-08 13:19:57 +02:00
evgeniysergeev
3bc5b07277 Fix for System.IO.InvalidDataException in VocLoader
Fix for VOC version check

use cached value from MoveNext instead of try/catch section
2019-05-15 21:20:24 +02:00
abcdefg30
cadbd0d9ab Change the year number in all cs headers from 2018 to 2019 2019-01-26 23:15:21 +01:00
Arular101
8a60918841 Update copyright notice year to 2018 2018-01-17 00:47:34 +01:00
RoosterDragon
7160c8a1a9 Allow multiple VocFormat streams.
VocFormat.GetPCMInputStream now returns independent streams, allowing multiple instances of the same source to be streamed.
2017-09-24 11:23:39 +01:00
RoosterDragon
7ed769421e Providing streaming WavFormat data.
WavFormat.GetPCMInputStream now returns data that is streamed, rather than a MemoryStream.
2017-09-24 11:23:39 +01:00
RoosterDragon
9413d9595c Providing streaming AudFormat data.
AudFormat.GetPCMInputStream now returns data that is streamed, rather than a MemoryStream.
2017-07-14 23:02:49 +01:00
Taryn Hill
43317e0f5d Update copyright notice year to 2017 2016-12-31 23:46:13 -06:00
RoosterDragon
226c0a050a Dispose some sound streams. 2016-12-23 19:37:17 +00:00
reaperrr
61acbe70d6 Extract WavReader to own file and move it to FileFormats 2016-06-23 23:47:57 +02:00
reaperrr
f1882e2dd6 Rename ImaAdpcmLoader to *Reader and move it to FileFormats 2016-06-23 23:47:55 +02:00
reaperrr
415e0bb54c Split AudReader from AudLoader and move it to FileFormats
We already separated loading from file format reading for sprites and videos.
2016-06-23 23:47:54 +02:00
reaperrr
ed210b380f Move audio loaders from engine to mod level 2016-06-23 23:47:52 +02:00