Skip to content

Commit b69a9d7

Browse files
committed
music & sound working, starting at wrong point
1 parent 97b26a5 commit b69a9d7

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

Qor/Audio.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Audio::Source :: Source(
6262
flags(_flags)
6363
{
6464
auto l = Audio::lock();
65+
source = std::make_shared<coal::Source>();
66+
s_pSpace->add(source);
6567
//alGenSources(1, &id);
6668
//if(flags & F_AUTOPLAY){
6769
// play();
@@ -397,6 +399,8 @@ Audio::Stream :: Stream(std::string fn):
397399
{
398400
source = std::make_shared<coal::Source>();
399401
m_pStream = std::make_shared<coal::Stream>(fn);
402+
source->add(m_pStream);
403+
s_pSpace->add(source);
400404
}
401405

402406
//void Audio::Stream :: init(std::string fn)

Qor/Audio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ class Audio
207207
//K_S_GET_SET(float, max_distance, m_MaxDist);
208208
//K_S_GET_SET(float, reference_distance, m_ReferenceDist);
209209

210+
static coal::Space* space() { return s_pSpace.get(); }
211+
210212
private:
211213
//ALCdevice* m_pDevice = nullptr;
212214
//ALCcontext* m_pContext = nullptr;

Qor/BasicState.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ BasicState :: BasicState(Qor* engine):
1818
m_pRoot(make_shared<Node>()),
1919
m_pRTTRoot(make_shared<Node>()),
2020
m_pPipeline(engine->pipeline()),
21-
m_pResources(engine->resources())
21+
m_pResources(engine->resources()),
22+
m_pMusic(engine->make<Sound>("loading.ogg")),
23+
m_pSound(engine->make<Sound>("test.wav"))
2224
{}
2325

2426
void BasicState :: preload()
@@ -27,6 +29,8 @@ void BasicState :: preload()
2729
m_pRoot->add(m_pCamera->as_node());
2830
m_pRTTCamera = make_shared<Camera>(m_pQor->resources(), m_pQor->window());
2931
m_pRTTRoot->add(m_pRTTCamera->as_node());
32+
m_pRoot->add(m_pMusic);
33+
m_pRoot->add(m_pSound);
3034
}
3135

3236
BasicState :: ~BasicState()
@@ -61,6 +65,9 @@ void BasicState :: enter()
6165
}, std::make_shared<MeshMaterial>(m_pRenderBuffer->texture())
6266
);
6367
m_pRoot->add(mesh);
68+
69+
m_pMusic->play();
70+
m_pSound->play();
6471
}
6572

6673
void BasicState :: logic(Freq::Time t)

Qor/BasicState.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "Text.h"
1414
#include "Menu.h"
1515
#include "RenderBuffer.h"
16+
#include "Sound.h"
1617

1718
class Qor;
1819

@@ -50,6 +51,9 @@ class BasicState:
5051
//unsigned m_DetailShader = ~0u;
5152

5253
//unsigned m_Shader = ~0u;
54+
55+
std::shared_ptr<Sound> m_pMusic;
56+
std::shared_ptr<Sound> m_pSound;
5357
};
5458

5559
#endif

Qor/Qor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void Qor :: logic()
199199
//t = m_pTimer->tick();
200200
++m_FramesLastSecond;
201201

202+
m_pAudio->update();
202203
m_pInput->logic(t);
203204
if(m_pInput->quit_flag())
204205
{

0 commit comments

Comments
 (0)