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

replace WinAudio with sfml SoundStream #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 11 additions & 4 deletions Main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include "WinAudio.h"
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <complex>
#include <math.h>
#include <fstream>
#include <cstring>

//Constants
static const int target_fps = 60;
Expand Down Expand Up @@ -125,9 +126,10 @@ static const Fractal all_fractals[] = {
chirikov,
};

//Synthesizer class to inherit Windows Audio.
class Synth : public WinAudio {
//Synthesizer class to inherit SoundStream.
class Synth : public sf::SoundStream {
public:
static const int AUDIO_BUFF_SIZE = 4096;
bool audio_reset;
bool audio_pause;
double volume;
Expand All @@ -136,7 +138,7 @@ class Synth : public WinAudio {
double play_nx, play_ny;
double play_px, play_py;

Synth(HWND hwnd) : WinAudio(hwnd, sample_rate) {
Synth(unsigned long int /*unused*/) {
audio_reset = true;
audio_pause = false;
volume = 8000.0;
Expand All @@ -148,6 +150,9 @@ class Synth : public WinAudio {
play_ny = 0.0;
play_px = 0.0;
play_py = 0.0;

initialize(2, sample_rate);
setLoop(true);
}

void SetPoint(double x, double y) {
Expand All @@ -157,6 +162,8 @@ class Synth : public WinAudio {
audio_pause = false;
}

virtual void onSeek(sf::Time /*unused*/) override {}

virtual bool onGetData(Chunk& data) override {
//Setup the chunk info
data.samples = m_samples;
Expand Down
8 changes: 2 additions & 6 deletions MandelbrotMusic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</ClCompile>
<Link>
<AdditionalLibraryDirectories>C:\Program Files\SFML\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>sfml-graphics-s-d.lib;sfml-system-s-d.lib;sfml-window-s-d.lib;opengl32.lib;winmm.lib;gdi32.lib;glu32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>sfml-graphics-s-d.lib;sfml-audio-d.lib;sfml-system-s-d.lib;sfml-window-s-d.lib;opengl32.lib;winmm.lib;gdi32.lib;glu32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
Expand Down Expand Up @@ -120,20 +120,16 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>C:\Program Files\SFML\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>sfml-graphics-s.lib;sfml-system-s.lib;sfml-window-s.lib;opengl32.lib;winmm.lib;gdi32.lib;glu32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>sfml-graphics-s.lib;sfml-audio-d.lib;sfml-system-s.lib;sfml-window-s.lib;opengl32.lib;winmm.lib;gdi32.lib;glu32.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
<ClCompile Include="WinAudio.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="frag.glsl" />
<None Include="vert.glsl" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="WinAudio.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
8 changes: 0 additions & 8 deletions MandelbrotMusic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WinAudio.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="frag.glsl">
Expand All @@ -30,9 +27,4 @@
<Filter>Header Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="WinAudio.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
128 changes: 0 additions & 128 deletions WinAudio.cpp

This file was deleted.

40 changes: 0 additions & 40 deletions WinAudio.h

This file was deleted.