Skip to content
This repository was archived by the owner on May 11, 2022. It is now read-only.

Commit 3e97a48

Browse files
committed
Fixed 'speed (by pitch)' error which would set this effect's value to default when switching to other track.
1 parent b29d912 commit 3e97a48

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

ide/BloodyPlayer.pro.user

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 4.9.2, 2019-08-18T14:40:32. -->
3+
<!-- Written by QtCreator 4.9.2, 2019-08-19T15:14:23. -->
44
<qtcreator>
55
<data>
66
<variable>EnvironmentId</variable>
@@ -317,7 +317,7 @@
317317
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
318318
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
319319
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
320-
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Home/Programming and computers/C/c++/Qt_projects/BloodyPlayer_release</value>
320+
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Home/Programming and computers/C/c++/Qt_projects/BloodyPlayer_debug</value>
321321
</valuemap>
322322
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
323323
</valuemap>

src/Model/AudioService/audioservice.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AudioService::AudioService(MainWindow* pMainWindow)
2121
{
2222
this->pMainWindow = pMainWindow;
2323
pSystem = nullptr;
24-
pRndGen = new std::mt19937_64(time(nullptr));
24+
pRndGen = new std::mt19937_64( static_cast<unsigned long long>(time(nullptr)) );
2525
iCurrentlyDrawingTrackIndex = new size_t(0);
2626

2727
bMonitorTracks = false;
@@ -273,7 +273,7 @@ void AudioService::addTracks(std::vector<wchar_t*> paths)
273273
}
274274

275275

276-
pMainWindow->showWaitWindow("Please wait.\nAdding tracks.");
276+
pMainWindow->showWaitWindow("Please wait.\nAdding your music.");
277277

278278
// Get amount of CPU threads
279279
// In every CPU thread we will add tracks
@@ -319,6 +319,8 @@ void AudioService::addTracks(std::vector<wchar_t*> paths)
319319
}
320320
else
321321
{
322+
// Just add them in one thread
323+
322324
for (size_t i = 0; i < paths.size(); i++)
323325
{
324326
addTrack(paths[i]);
@@ -327,18 +329,21 @@ void AudioService::addTracks(std::vector<wchar_t*> paths)
327329
delete allCount;
328330
pMainWindow->hideWaitWindow();
329331

332+
// Wait a little for all track widgets to show
330333
std::this_thread::sleep_for(std::chrono::milliseconds(100));
331334
if (tracks.size() > 0) pMainWindow->setFocusOnTrack(tracks.size() - 1);
332335

333336
mtxTracksVec.unlock();
334337
return;
335338
}
336339

340+
// Check loop if all threads are done
337341
bool bDone;
338342
do
339343
{
340344
bDone = true;
341345

346+
// Wait a little for all track widgets to show
342347
std::this_thread::sleep_for(std::chrono::milliseconds(100));
343348

344349
for (size_t i = 0; i < threadsDoneFlags.size(); i++)
@@ -362,6 +367,7 @@ void AudioService::addTracks(std::vector<wchar_t*> paths)
362367

363368
pMainWindow->hideWaitWindow();
364369

370+
// Wait a little for all track widgets to show
365371
std::this_thread::sleep_for(std::chrono::milliseconds(100));
366372
if (tracks.size() > 0) pMainWindow->setFocusOnTrack(tracks.size() - 1);
367373

@@ -393,7 +399,7 @@ void AudioService::playTrack(size_t iTrackIndex, bool bDontLockMutex)
393399
}
394400

395401

396-
// Play track
402+
// Stop currently playing track
397403
if (bIsSomeTrackPlaying)
398404
{
399405
if (iTrackIndex != iCurrentlyPlayingTrackIndex)
@@ -408,6 +414,7 @@ void AudioService::playTrack(size_t iTrackIndex, bool bDontLockMutex)
408414
pMainWindow->removePlayingOnTrack(iCurrentlyPlayingTrackIndex);
409415
}
410416

417+
// Play track
411418
if ( tracks[iTrackIndex]->playTrack(fCurrentVolume) )
412419
{
413420
bIsSomeTrackPlaying = true;

src/Model/Track/track.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,14 @@ bool Track::playTrack(float fVolume)
251251
return false;
252252
}
253253

254-
if (fSpeedByFreq == 1.0f)
254+
if ( (fSpeedByFreq == 1.0f) && (fSpeedByTime == 1.0f) )
255255
{
256256
pChannel->setFrequency( fDefaultFrequency );
257257
}
258258
else
259259
{
260-
pChannel->setFrequency( fDefaultFrequency * fSpeedByFreq );
261-
}
262-
263-
if (fSpeedByTime == 1.0f)
264-
{
265-
pChannel->setFrequency( fDefaultFrequency );
266-
}
267-
else
268-
{
269-
pChannel->setFrequency( fDefaultFrequency * fSpeedByTime );
260+
if (fSpeedByFreq != 1.0f) pChannel->setFrequency( fDefaultFrequency * fSpeedByFreq );
261+
else pChannel->setFrequency( fDefaultFrequency * fSpeedByTime );
270262
}
271263

272264
result = pChannel->setPaused(false);
@@ -361,22 +353,14 @@ bool Track::playTrack(float fVolume)
361353
}
362354
}
363355

364-
if (fSpeedByFreq == 1.0f)
356+
if ( (fSpeedByFreq == 1.0f) && (fSpeedByTime == 1.0f) )
365357
{
366358
pChannel->setFrequency( fDefaultFrequency );
367359
}
368360
else
369361
{
370-
pChannel->setFrequency( fDefaultFrequency * fSpeedByFreq );
371-
}
372-
373-
if (fSpeedByTime == 1.0f)
374-
{
375-
pChannel->setFrequency( fDefaultFrequency );
376-
}
377-
else
378-
{
379-
pChannel->setFrequency( fDefaultFrequency * fSpeedByTime );
362+
if (fSpeedByFreq != 1.0f) pChannel->setFrequency( fDefaultFrequency * fSpeedByFreq );
363+
else pChannel->setFrequency( fDefaultFrequency * fSpeedByTime );
380364
}
381365

382366
result = pChannel->setPaused(false);
@@ -575,6 +559,7 @@ void Track::setMaxPosInGraph(unsigned int iMax)
575559

576560
void Track::setSpeedByFreq(float fSpeed)
577561
{
562+
// Save the value even if pChannel is not created
578563
fSpeedByFreq = fSpeed;
579564

580565
if (pChannel != nullptr)
@@ -592,6 +577,7 @@ void Track::setSpeedByFreq(float fSpeed)
592577

593578
void Track::setSpeedByTime(float fSpeed)
594579
{
580+
// Save the value even if pChannel is not created
595581
fSpeedByTime = fSpeed;
596582

597583
if (pChannel != nullptr)

0 commit comments

Comments
 (0)