Skip to content
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

Modern C# - .NET 6 #103

Draft
wants to merge 34 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2e5506c
NO ERRORS - .net 6 first commit
Kermalis Sep 4, 2022
a20fae5
Why was this in the wrong project BRO
Kermalis Sep 5, 2022
e3f0e14
Middle C should be C5 since MIDI starts at C-1
Kermalis Sep 5, 2022
2cc1293
Ignore me I'm dumb
Kermalis Sep 5, 2022
2c3b1c3
Fix HSL colors
Kermalis Sep 5, 2022
5bc23a0
Use RGB colors in config
Kermalis Sep 5, 2022
a75c611
Fix MIDI tracks overwriting each other
Kermalis Sep 6, 2022
0729be9
Fix MTrk size
Kermalis Sep 6, 2022
36ab8af
MIDIs are good now
Kermalis Sep 6, 2022
618a405
Fix program icon
Kermalis Sep 6, 2022
3c2d1d7
Prevent this from getting optimized out
Kermalis Sep 7, 2022
568f5db
Update VG Music Studio - Core.csproj
Kermalis Sep 8, 2022
f7157b2
Update ValueTextBox.cs
Kermalis Sep 8, 2022
5b633cc
Update TrackViewer.cs
Kermalis Sep 8, 2022
a6d2ea9
Update TimeBarrier.cs
Kermalis Sep 8, 2022
eead4ed
Cache key strings
Kermalis Sep 8, 2022
840332e
Update translations + add Russian/French
Kermalis Sep 8, 2022
4a9524f
Update Assembler.cs
Kermalis Sep 11, 2022
aaa7d02
Fat commit
Kermalis Sep 12, 2022
8ef1e7e
Fix crash
Kermalis Sep 12, 2022
0ed511d
[DSE] Align chunks to 16 bytes
Kermalis Sep 13, 2022
4f98708
[MP2K] Add F-Zero games
Kermalis Sep 14, 2022
e52aac4
[MP2K] Add remaining Final Fantasy games
Kermalis Oct 20, 2022
7cde095
Fix file copying in new VGMS version
Kermalis Oct 20, 2022
9e90950
[MP2K] Yoshi Topsy-Turvy: all regions
Kermalis Mar 26, 2023
df646b7
[MP2K] Kirby & The Amazing Mirror
Kermalis Apr 7, 2023
d6341c4
Use KMIDI
Kermalis Apr 7, 2023
0449588
Some changes I did a while ago idk
Kermalis May 14, 2023
016c3e4
Address all warnings
Kermalis May 14, 2023
cc44ec3
MORE SPAN
Kermalis May 14, 2023
66ab16a
C key names on the piano
Kermalis May 14, 2023
95dafe0
OOOOOOOOOOOOOOOOOPS
Kermalis Jun 7, 2023
a556eba
Fix crash
Kermalis Jun 27, 2023
b0d14fb
[MP2K] Sonic Advance 2
Kermalis Feb 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ If you want to talk or would like a game added to our configs, join our [Discord
### General
* Stich991 - Italian translation
* tuku473 - Design suggestions, colors, Spanish translation
* Lachesis - French translation
* Delusional Moonlight - Russian translation

### AlphaDream Engine
* irdkwia - Finding games that used the engine
Expand Down
94 changes: 94 additions & 0 deletions VG Music Studio - Core/ADPCMDecoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;

namespace Kermalis.VGMusicStudio.Core;

internal struct ADPCMDecoder
{
private static ReadOnlySpan<short> IndexTable => new short[8]
{
-1, -1, -1, -1, 2, 4, 6, 8,
};
private static ReadOnlySpan<short> StepTable => new short[89]
{
00007, 00008, 00009, 00010, 00011, 00012, 00013, 00014,
00016, 00017, 00019, 00021, 00023, 00025, 00028, 00031,
00034, 00037, 00041, 00045, 00050, 00055, 00060, 00066,
00073, 00080, 00088, 00097, 00107, 00118, 00130, 00143,
00157, 00173, 00190, 00209, 00230, 00253, 00279, 00307,
00337, 00371, 00408, 00449, 00494, 00544, 00598, 00658,
00724, 00796, 00876, 00963, 01060, 01166, 01282, 01411,
01552, 01707, 01878, 02066, 02272, 02499, 02749, 03024,
03327, 03660, 04026, 04428, 04871, 05358, 05894, 06484,
07132, 07845, 08630, 09493, 10442, 11487, 12635, 13899,
15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794,
32767,
};

private byte[] _data;
public short LastSample;
public short StepIndex;
public int DataOffset;
public bool OnSecondNibble;

public void Init(byte[] data)
{
_data = data;
LastSample = (short)(data[0] | (data[1] << 8));
StepIndex = (short)((data[2] | (data[3] << 8)) & 0x7F);
DataOffset = 4;
OnSecondNibble = false;
}

public static short[] ADPCMToPCM16(byte[] data)
{
var decoder = new ADPCMDecoder();
decoder.Init(data);

short[] buffer = new short[(data.Length - 4) * 2];
for (int i = 0; i < buffer.Length; i++)
{
buffer[i] = decoder.GetSample();
}
return buffer;
}

public short GetSample()
{
int val = (_data[DataOffset] >> (OnSecondNibble ? 4 : 0)) & 0xF;
short step = StepTable[StepIndex];
int diff =
(step / 8) +
(step / 4 * (val & 1)) +
(step / 2 * ((val >> 1) & 1)) +
(step * ((val >> 2) & 1));

int a = (diff * ((((val >> 3) & 1) == 1) ? -1 : 1)) + LastSample;
if (a < short.MinValue)
{
a = short.MinValue;
}
else if (a > short.MaxValue)
{
a = short.MaxValue;
}
LastSample = (short)a;

a = StepIndex + IndexTable[val & 7];
if (a < 0)
{
a = 0;
}
else if (a > 88)
{
a = 88;
}
StepIndex = (short)a;

if (OnSecondNibble)
{
DataOffset++;
}
OnSecondNibble = !OnSecondNibble;
return LastSample;
}
}
File renamed without changes.
Loading