Skip to content

Commit

Permalink
BMSON support and bms loader refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoru committed Oct 11, 2015
1 parent bfeaa1f commit 2d72a7d
Show file tree
Hide file tree
Showing 27 changed files with 1,429 additions and 1,041 deletions.
10 changes: 8 additions & 2 deletions project/vs10.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v120_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -118,8 +118,9 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
<OmitFramePointers>true</OmitFramePointers>
<OmitFramePointers>false</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -163,6 +164,7 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\ext-src\jsoncpp.cpp" />
<ClCompile Include="..\ext-src\lua.c" />
<ClCompile Include="..\ext-src\pa_ringbuffer.c" />
<ClCompile Include="..\ext-src\sha256.cpp" />
Expand Down Expand Up @@ -190,6 +192,7 @@
<ClCompile Include="..\src\IPC.cpp" />
<ClCompile Include="..\src\Line.cpp" />
<ClCompile Include="..\src\Logging.cpp" />
<ClCompile Include="..\src\NoteLoaderBMSON.cpp" />
<ClCompile Include="..\src\NoteLoaderOJN.cpp" />
<ClCompile Include="..\src\Noteskin.cpp" />
<ClCompile Include="..\src\NoteTransformations.cpp" />
Expand Down Expand Up @@ -326,6 +329,9 @@
<ItemGroup>
<ResourceCompile Include="app.rc" />
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
9 changes: 9 additions & 0 deletions project/vs10.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@
<ClCompile Include="..\src\NoteTransformations.cpp">
<Filter>Source\vsrg\gameplay</Filter>
</ClCompile>
<ClCompile Include="..\ext-src\jsoncpp.cpp">
<Filter>Source\libraries</Filter>
</ClCompile>
<ClCompile Include="..\src\NoteLoaderBMSON.cpp">
<Filter>Source\vsrg\internal</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\ActorLifebar.h">
Expand Down Expand Up @@ -579,4 +585,7 @@
<ItemGroup>
<ResourceCompile Include="app.rc" />
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
</ItemGroup>
</Project>
19 changes: 16 additions & 3 deletions src/Audiofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ AudioSample::AudioSample()
mIsLooping = false;
mData = nullptr;

mAudioStart = 0;
mAudioEnd = std::numeric_limits<float>::infinity();
MixerAddSample(this);
}

Expand Down Expand Up @@ -171,12 +173,15 @@ bool AudioSample::Open(AudioDataSource* Src)
delete mData;
mBufferSize = size;
mData = mDataNew;
mRate = 44100;
}

mCounter = 0;
mIsValid = true;
mByteSize = mBufferSize * sizeof(short);

mAudioEnd = (float(mBufferSize) / (float(mRate) * Channels));

return true;
}
return false;
Expand All @@ -189,10 +194,11 @@ uint32 AudioSample::Read(short* buffer, size_t count)

if (mIsValid)
{
size_t bufferLeft = mBufferSize-mCounter;
size_t limit = (mRate * Channels * mAudioEnd);
size_t bufferLeft = limit - mCounter;
uint32 ReadAmount = min(bufferLeft, count);

if (mCounter < mBufferSize)
if (mCounter < limit)
{
memcpy(buffer, mData+mCounter, ReadAmount * sizeof(short));
mCounter += ReadAmount;
Expand All @@ -213,6 +219,13 @@ bool AudioSample::IsPlaying()
return mIsPlaying;
}

void AudioSample::Slice(float audio_start, float audio_end)
{
float audioDuration = float(mBufferSize) / (float(mRate) * Channels);
mAudioStart = Clamp(audio_start, 0.0f, audioDuration);
mAudioEnd = Clamp(audio_end, mAudioStart, audioDuration);
}

GString RearrangeFilename(const char* Fn)
{
GString Ret;
Expand Down Expand Up @@ -252,7 +265,7 @@ bool AudioSample::Open(const char* Filename)
void AudioSample::Play()
{
mIsPlaying = true;
mCounter = 0;
mCounter = mAudioStart * mRate * Channels;
}

void AudioSample::SeekTime(float Second)
Expand Down
2 changes: 2 additions & 0 deletions src/Audiofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class AudioSample : public Sound
uint32 mByteSize;
uint32 mBufferSize;
uint32 mCounter;
float mAudioStart, mAudioEnd;
short* mData;
bool mValid;
bool mIsPlaying;
Expand All @@ -75,6 +76,7 @@ class AudioSample : public Sound
void Stop();

bool IsPlaying();
void Slice(float audio_start, float audio_end);
};

class AudioStream : public Sound
Expand Down
2 changes: 1 addition & 1 deletion src/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void ConvertToOM(VSRG::Song *Sng, Directory PathOut, GString Author)
{
for (uint8 n = 0; n < Difficulty->Channels; n++)
{
for (auto Note : k.MeasureNotes[n])
for (auto Note : k.Notes[n])
{
if (Difficulty->IsWarpingAt(Note.StartTime)) continue;

Expand Down
4 changes: 2 additions & 2 deletions src/ConvertToBMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ class BMSConverter : public VSRG::RowifiedDifficulty {
uint32 Measure = 0;
using std::endl;
for (auto M : Measures){
if (Parent->Data->Measures[Measure].MeasureLength != 4)
if (Parent->Data->Measures[Measure].Length != 4)
{
double bmsLength = Parent->Data->Measures[Measure].MeasureLength / 4;
double bmsLength = Parent->Data->Measures[Measure].Length / 4;
OutFile << boost::format("#%03d02:%f") % Measure % bmsLength << endl;
}

Expand Down
2 changes: 1 addition & 1 deletion src/NPSGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NPSGraph {
int out = 0;
for (auto m : In->Data->Measures) {
for (int k = 0; k < In->Channels; k++) {
for (auto note : m.MeasureNotes[k]) {
for (auto note : m.Notes[k]) {
if (note.StartTime >= timeStart || (note.EndTime >= timeStart && note.EndTime) ) {
if (note.StartTime < timeEnd || (note.EndTime < timeEnd && note.EndTime)) {
out++;
Expand Down
5 changes: 5 additions & 0 deletions src/NoteLoader7K.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ namespace NoteLoaderOJN
void LoadObjectsFromFile(GString filename, GString prefix, VSRG::Song *Out);
}

namespace NoteLoaderBMSON
{
void LoadObjectsFromFile(GString filename, GString prefix, VSRG::Song *Out);
}

#endif
Loading

0 comments on commit 2d72a7d

Please sign in to comment.