I'm looking for some help to get the audio library SoLoud to work I've written out the quickstart from the documentation page here https://sol.gfxile.net/soloud/quickstart.html, opting for the static library route, but it doesn't seem to play no matter what I've tried many different wav files, I've stepped through and the file seems to be loading correctly and no failures in any of the methods seem to be occurring. everything seems to be included and linking correctly as I've got no errors of any kind anywhere. just no sound. I'm thinking maybe I've set it up incorrectly somehow but I can't find anything wrong. Anyway, here's the source any help would be appreciated.
#include "soloud.h"
#include "soloud_wav.h"
int main()
{
SoLoud::Soloud gSoloud; // SoLoud engine
SoLoud::Wav gWave; // One wave file
gSoloud.init(); // Initialize SoLoud
int x = gWave.load("A.wav"); // Load a wave
std::cout << x << std::endl;
gSoloud.play(gWave); // Play the wave
std::cout << "Hello World!\n";
} ```
Silly me forgetting my thread logic the process terminates when the program ends and its child threads that are playing the audio die as per the OS. Which I forgot. So the simple solution is a loop and there you have it audio.
Related
I have a very weird problem. The setup is the following:
Library A uses Library B
Both libraries are installed as shared library independently and A links to B using CMake packages.
When I create an executable that directly links to B, everything works fine.
When I create an executable that links to A however, which is using B, then for some reason my fstream in B fails to open a specific file. I am 100% certain the file exists, is not requiring authorization and is not currently used. The error thrown by strerror(errno) is "No such file or directory".
I really have no clue what might go wrong. This is the code snippet I use for opening:
ifstream f;
f.open(filename.c_str(), ios_base::in|ios::binary);
if (f.fail()) {
std::cout << "Opening Vocabulary failed: " << std::strerror(errno) << std::endl;
return false;
}
I triple checked the path in filename is correct. These are the last resorts I can think of:
Maybe Library A uses another C++ Standard as B, which is why the call to fstream fails?
Maybe filename string is somehow corrupted, even though the path seems to be correct?
Maybe some memory leak corrupts my c_str() command?
Is there anything else that I could check?
Edit: Ah, one thing I forgot: The fstream command is in a templated function in a header file. Maybe this has something to do with it?
Edit2: Here is the stack trace. "ORBVoc.bin" is the file I wanted to open. The only information I get out of this is, it does not exist...though it does exist.
https://www.file-upload.net/download-14359408/strace.log.html
Okay, apparently a reboot was all it takes. Today everything works flawlessly. No permissions, file or line of code was changed. I assume either something went terribly wrong, when my Laptop came back from hibernation. Or it was some pending ubuntu update? I really have no idea. I could swear it was shutdown at least once the past 2-3 days. But jeah, I have no other explanation. Maybe someone smarter can answer this with his glass ball...
Anyway, thanks for the answers, appreciate it! At least I learned about strace $:^)
I got an error while debuging a program i wrote down from a tutorial online, it is a sound synth made by the one lone coder on youtube. I'm not sure what caused it or how to fix it. I disabled pre-compiled headers witch was the first problem i encounterd.
I have tried searching online, leading me here to awnsers about code of others, i have tried going on multiple discord servers and asking there.
No luck so far. Also this is just as a little exercise to help me get back on track.
Main.cpp
#include <iostream>
#include "olcNoiseMaker.h"
using namespace std;
double MakeNoise(double dTime) {
return 0.5 * sin(540.0 * 2 * 3.14159 * dTime);
}
int main() {
wcout << "onelonecoder.com - synth part 1" << endl;
//Get all sound hardware
vector<wstring> devices = olcNoiseMaker<short>::Enumerate();
//Display finding
for (auto d : devices) wcout << "Found output device:" << d << endl;
//Create sound machine
olcNoiseMaker<short> sound(devices[0], 44100, 1, 8, 512);
//Link noise function whit machine
sound.SetUserFunction(MakeNoise);
return 0;
}
olcNoiseMaker.h is just to get acces to the sound chip and bla bla.
you can see his video here: https://www.youtube.com/watch?v=tgamhuQnOkM&t=134s
Running the program should result in a contenious sine wave of 540 KHz
instead it plays it only once and gives me this error:
Unhandled exception thrown: write access violation.
_Tgt was 0xA4EFF82C. occurred
Late to answer, but I had this issue (Visual Studio 2019). When I built and ran the program, there was just one short beep before the program exited. The issue was that I was in the x64 Debug configuration, and that was causing the error. Once I changed to x86 Debug, it was working perfectly.
Edit: Also, in your code, you are missing the while(1) {} after the sound.SetUserFunction(MakeNoise); statement which would be needed to get the code working according to the video.
Alright, I'm a little bit (honestly way too) confused about how the heck I can make a program interact with another program.
For example, let's say a game, a shooter, when you run an external program and you make your character not able to die, or immediately shoot when detects an enemy, etc...
I was reading a little bit about it, and they say you have to know how the "target" is composed. But I still don't get it.
For example, let's say we've got a simple code like this:
#include <iostream>
#include <windows.h>
int main() {
for(int h = 0; ; h++) {
std::cout << "The H's value is: " << h << std::endl;
Sleep(1000);
}
return 0;
}
Then, how do I create another program where I can change the H's value to zero everytime I press any key?
Don't get me wrong, I ain't trying to hack anyone or anything, I'm just curious about how those programs work.
(Sorry if I've got some grammar issues, English isn't my native language).
Specific to your program in the exapmle if we take that the program is already compiled and you are not allowed to make any changes to the source code the solution would be to build a program which will run with high enough privileges to examine this process's memory and directly change the in-memory value of h, which should be on the top of the stack(or almost).
Speaking of some more "legal" ways to do so you should check you should read about inter process communication which can be done with multiple methods. Read this.
However most "Bots" and programs which help cheaters in games are in many cases graphics based and are able to analyse the image and thus help aim. On the other hand some "recoil reducers" simply move your mouse in the opposite direction of the recoil of the gun in game. So there is a ton of approaches to your question and for every particular case the answer might be different.
I wrote a C++ program that uses opencv, I compiled it in VisualStudio 2010 using release mode as Win32 application, the opencv library is dynamically linked so I just copied the needed dll's to the root folder of the program(so I can run it on other computers), the program is tracking people in a video and works fine when I run it on my computer, however when I run it on other machines it works but 65% slower, at first I thought that its the machine it self that is slow, but then I wrote another small program(the code is below) whose only purpose is to read a video file and play it approximately at the original video speed. Unfortunately I have the same issue with it as well, it runs fine on my computer but when I run it on other computers it slows down by 65%(more or less), I am new to c++/opencv and I have no real idea why this is happening I'm hoping some one can enlighten me, was the dynamic linking a bad idea? and I should compile opencv as a static library(which I don't yet know how to do and will appreciate any help on the issue). or is it something else?
#include "opencv\cv.h"
#include "opencv\highgui.h"
int main(){
cv::VideoCapture vidBuffer;
if(!vidBuffer.open("res/test.mp4")){
std::cerr << "Cant find \"res/test.mp4\"\n";
system("pause");
return -1;
}
int fps = vidBuffer.get(CV_CAP_PROP_FPS);
int frameTime = 1000/fps;
//video loop
cv::Mat frame;
for(char c=-1;;c=cv::waitKey(frameTime)){
if(!vidBuffer.read(frame)||c==27)
break;
cv::imshow("Vidoe test", frame);
}
//loop emd
vidBuffer.release();
return 0;
}
when I'm trying to compile it gives me 26 errors however everything is at its right place
but won't able to understand the errors mostly constant is too long.
Plz help I want to play a mp3 file through C programming.
*errors are shown in the jpg image
#include "inc/fmod.h"
FMUSIC_MODULE* handle;
int main ()
{
// init FMOD sound system
FSOUND_Init (44100, 32, 0);
// load song
handle=FMUSIC_LoadSong ("don.mp3");
// play song only once
// when you want to play a midi file you have to disable looping
// BEFORE playing the song else this command has no effect!
FMUSIC_SetLooping (handle, false);
// play song
FMUSIC_PlaySong (handle);
// wait until the users hits a key to end the app
while (!_kbhit())
{
}
//clean up
FMUSIC_FreeSong (handle);
FSOUND_Close();
}
http://i.stack.imgur.com/JH4Ts.jpg
Borland Turbo C++ pre-dates most C++ standards and modern C. I would not expect FMOD or any modern library to work with this compiler.
Visual C++ is free to use in the Express form, and is a vastly better compiler.
The code you have listed is FMOD 3 code, yet you are using FMOD 4 headers (and probably libs too). This will not work, I can see from your error pic you have other troubles too, perhaps include paths not being set correctly.
We provide a Borland lib that you will need to link with: 'fmodex_bc.lib' but again this is FMOD 4 code, I would highly recommend looking at the 'playstream' example that ships with the SDK, it demonstrates MP3 playback.