Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleP committed Apr 9, 2024
1 parent 521a793 commit 5fe053c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/modules/audio/wrap_Source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ namespace Wrap_Source
int stop(lua_State* L);

int setLooping(lua_State* L);

int tell(lua_State* L);
} // namespace Wrap_Source
8 changes: 7 additions & 1 deletion platform/cafe/include/driver/DigitalSound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,14 @@ namespace love
if (auto result = AXSetVoiceSrcRatio(this->buffers[index], ratio); result != 0)
return false;

AXSetVoiceCurrentOffset(this->buffers[index], 0);
AXSetVoiceSrcType(this->buffers[index], AX_VOICE_SRC_TYPE_LINEAR);
this->buffers[index]->offsets.dataType = (AXVoiceFormat)format;

AXVoiceOffsets offsets {};
AXGetVoiceOffsets(this->buffers[index], &offsets);

offsets.dataType = (AXVoiceFormat)format;
AXSetVoiceOffsets(this->buffers[index], &offsets);

AXVoiceEnd(this->buffers[index]);
}
Expand Down
3 changes: 2 additions & 1 deletion platform/cafe/include/driver/DigitalSoundMix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ static AXVoiceDeviceMixData STEREO_MIX[2][AX_NUM_CHANNELS] =
}
};

static AXVoiceDeviceMixData MONO_MIX[1][AX_NUM_CHANNELS] = {
static AXVoiceDeviceMixData MONO_MIX[1][AX_NUM_CHANNELS] =
{
{ // AX_VOICE(0)
{ // AX_CHANNEL_LEFT
.bus = { { .volume = 0x8000 } }
Expand Down
5 changes: 3 additions & 2 deletions platform/cafe/source/driver/DigitalSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ namespace love
if (buffer == nullptr || data == nullptr)
return;

AXVoiceBegin(buffer);
DCFlushRange(data, size);

DCStoreRange(data, size);
AXVoiceBegin(buffer);

AXSetVoiceState(buffer, AX_VOICE_STATE_STOPPED);
AXSetVoiceLoop(buffer, looping ? AX_VOICE_LOOP_ENABLED : AX_VOICE_LOOP_DISABLED);
Expand All @@ -97,6 +97,7 @@ namespace love
offsets.data = (int16_t*)data;
offsets.currentOffset = 0;
offsets.endOffset = nsamples;
offsets.loopOffset = 0;

AXSetVoiceOffsets(buffer, &offsets);

Expand Down
18 changes: 17 additions & 1 deletion source/modules/audio/wrap_Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,30 @@ int Wrap_Source::setLooping(lua_State* L)
return 0;
}

int Wrap_Source::tell(lua_State* L)
{
auto* self = luax_checksource(L, 1);

auto type = Source::UNIT_SECONDS;
const char* name = lua_isnoneornil(L, 2) ? nullptr : lua_tostring(L, 2);

if (name && !Source::getConstant(name, type))
return luax_enumerror(L, "time unit", Source::SourceUnits, name);

lua_pushnumber(L, self->tell(type));

return 1;
}

// clang-format off
static constexpr luaL_Reg functions[] =
{
{ "clone", Wrap_Source::clone },
{ "play", Wrap_Source::play },
{ "pause", Wrap_Source::pause },
{ "stop", Wrap_Source::stop },
{ "setLooping", Wrap_Source::setLooping }
{ "setLooping", Wrap_Source::setLooping },
{ "tell", Wrap_Source::tell }
};
// clang-format on

Expand Down

0 comments on commit 5fe053c

Please sign in to comment.