C++ Oscillator not confirming finding sound source or emitting wave

I'm trying to follow along in a tutorial of how to code to an oscillator on youtube. Idk if I can link the video without breaking rules here.

I am using codelite as my IDE.

There's two files. One main with the math function included, and a header file that does some stuff with the audio card according provided by the author of the youtube channel. I have no clue what this does.

Basically, this first block of code is the one I wrote following the instructions. This is supposed to do the math to produce the sin wave, and connect with the audio devices to output it.

But when I run the program, no cout messages, just Press Enter Key to continue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <vector>
using namespace std;

#include "olcNoiseMaker.h"
#pragma comment(lib, "lib_you_needed_name")
// in your case it would be
#pragma comment(lib, "winmm.lib")
double MakeNoise(double dTime){
	return 0.5 *sin(440.0 * 2 * 3.14159 * dTime);
}
int main()
{
	wcout << "onelonecoder.com -synthesizer Part 1" << endl;
	//Get all sound hardware
	vector<wstring> devices = olcNoiseMaker<short>::Enumerate();
	
	// Display findings
	for (auto d : devices) wcout << "Found Output Device:" << d << endl;
	
	// Create sound machine!!
	olcNoiseMaker<short> sound(devices[0], 44100, 1, 8, 512); //sample rate, channel, 8 bits , ?
	
	// Link noise function with sound machine 
	sound.SetUserFunction(MakeNoise);
	
	while(1)
	{
	
	}
	return 0;
}


This is the sound card file provided by the youtube tutorial.

This is the link to the github for the headerfile since I can't copy paste it here without exceeding the character limit.
https://github.com/OneLoneCoder/synth/blob/master/olcNoiseMaker.h

Also, here's the errors I'm getting:
1
2
3
4
5
6
7
8
9
10
11
12
C:/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/mingw32-make.exe -j12 SHELL=cmd.exe -e -f  Makefile
"----------Building project:[ OscillatoR - Debug ]----------"
OscillatoR.mk:99: warning: overriding recipe for target '../build-Debug/OscillatoR/up_up_up_Crafts_Programming_C++'
OscillatoR.mk:97: warning: ignoring old recipe for target '../build-Debug/OscillatoR/up_up_up_Crafts_Programming_C++'
OscillatoR.mk:102: warning: overriding recipe for target '../build-Debug/OscillatoR/up_up_up_Crafts_Programming_C++'
OscillatoR.mk:99: warning: ignoring old recipe for target '../build-Debug/OscillatoR/up_up_up_Crafts_Programming_C++'
mingw32-make.exe[1]: Entering directory 'C:/Users/david/OneDrive/Desktop/codelite/Oscillator v2/OscillatoR'
mingw32-make.exe[1]: *** No rule to make target '../../../Crafts/Programming/C++', needed by '../build-Debug/OscillatoR/up_up_up_Crafts_Programming_C++'.  Stop.
mingw32-make.exe[1]: *** Waiting for unfinished jobs....
mingw32-make.exe: *** [Makefile:5: All] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/david/OneDrive/Desktop/codelite/Oscillator v2/OscillatoR'
=== build ended with warnings (0 errors, 4 warnings) ===
Last edited on
The #pragma comment() statements strewn throughout the code would give the impression this is code compileable in Visual Studio. It is one way how WinAPI libraries are added to the linker list. I don't know if codelite understands those commands.

Another thing that stands out for me is using "wide" versions of std::cout and std::string.

This code is used in the Code-It-Yourself sound synthesizer videos on the onelonecoder.com blog

You might have better luck getting help there.
Last edited on
I checked the blog and didn't find anything, I'll look again then though. I'm infamous for looking directly at the solution and missing it, hahaha.

In the tutorial, he was using Visual Studio so that makes sense.
A meta-search link might be helpful to find easier to use ideas.

https://duckduckgo.com/?q=C%2B%2B+windows+synthesizer&t=ffsb&ia=web

The first link in that search, The Synthesis ToolKit in C++ (STK), has the advantage of being updated more recently than the headers you are trying to use.

Beyond this I really can't help 'cuz I don't "do synth" at all.
Last edited on
Topic archived. No new replies allowed.