C++ :: Play Audio File As Background While Executing Other Operations
Jun 6, 2013I need to make a program which can play a audio file as background while executing other operations .
View 4 RepliesI need to make a program which can play a audio file as background while executing other operations .
View 4 RepliesI got this code from a wiki that taught me how to make C code that plays audio, and with a few changes I was able to get it to take a command-line argument as the music file name. Here it is
Code:
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
int main(int argc, char *argv[])
[Code] ....
The only problem is, even though I guess it needs to create a window to work with SDL, is there any way you could hide it or something so the user can't see it? I don't really want to see it ( I'm planning on running it from Batch files or C applications as an easy way to play an audio file once ), because if I did, I might as well just use a default audio player instead.
I understand how to play a .wav file in a program, but I am attempting to "package" the .wav file with the project so that it can be played by another person, on a different machine (namely, my professor). The way I have come to understand this is that if you use the following line of code:
PlaySound(TEXT("C:WindowsMedia
otify.wav"), NULL, SND_FILENAME);
The sound file would not play if it is not in the same location on the other computer. Am I correct? Assuming that I am, I have added the file that I wish to play as a resource in my project, but I can't figure out how to make it play. Looking at MSDN (and other resources) I found the following snippet:
#define MAKEINTRESOURCE
PlaySound(
MAKEINTRESOURCE(L"notify.wav"),
GetModuleHandle(NULL),
SND_RESOURCE);
I get no errors when I build the program, but no sound plays when I run it. I have tried for hours now to figure this out (which is usually enough time for me to sort through the problem) but I have met with no success. This leads me to believe I am either completely off in my assumptions, or I am making a silly mistake.
How can i play a mp3 file in the background?How can i rule the volume of the mp3 file?why does delay(0.25) doesnt work in this code?
Code:
FILE *datei;
char line[ANZAHL][LAENGE];
int i ;
datei = fopen ("song.txt", "r");
if (datei != NULL){
for(i = 0; i < ANZAHL;i++) {
delay(0.25);
fgets(line,LAENGE,datei);
printf ("%s
[code]....
i have a audio file that i want to play via C+.
View 4 Replies View Relatedi want to create a program (in c++ or c#) that will play mp3 files but also display a word file with the lyrics of the mp3 song playing. so if i choose a mp3 file from a list, the lyric file for that song should also be displayed. i have all the mp3 and lyric files saved on the computer so my problem is how can i link the files?
View 5 Replies View Relatedhow to open an audio file using c. write a code to open an audio file.
View 2 Replies View RelatedI making a application which convert video to audio in MFC. i want make it without using FFMPEG . How can it possible.
View 1 Replies View RelatedI am trying to get user's voice as an audio input to a c++ program and store it in a text file (.txt)
I have been searching over the web to find some kind of library or something like OpenCV(video library) for while now but nothing seems to be there.
I'm looking to convert audio, images, video to base64 in c++, and through many searches on the web I've only seem to come up with string > base64.
When I view a .mp3 file for example, there are many characters there that are not available to be used in my string to encode.
[URL] ....
I have this code set up in my project, and all I want is to be able to give the location of any file and have it encode (could just encode to a string, I can handle writing it to a file), and then give a location to put the decoded file as well.
I'm not sure exactly where to even start.
I keep getting this error when trying to compile.
error C2440: 'initializing' : cannot convert from 'void' to 'std::basic_ifstream<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> Expressions of type void cannot be converted to other types
Here is my entire program:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
[code].....
Here's the code I'm writing:
Code:
#include <stdio.h>
#include <stdlib.h>
char* getTeamCode(char* team);
[Code]....
Why the placement of the code on line 21 above matters.
It grabs the correct string just fine. If I write a printf just below it, it prints the string it should correctly. However, if I do a printf of the string OSUteamCode below the fopen call on line 23, it prints blank.
So the first thing I did was move it below the fopen line. It worked, finding and outputting the first game in "game.csv" just fine, but not the other 11. Debugging with printf shows that the contents of OSUteamCode again disappear after the fopen call in the addLineCSV function.
I'm not understanding why that happens. The only thing I can figure is there's something going on with the file I/O commands that I just don't understand, but I can't find anything online that explains what that might be.
I am trying to write my files to another subfolder . Below is my program.
Code:
cat th6.c
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#define SIZE 8
#define NUMELM 8
[Code] ....
I observe my filename along with directory as text in the new file created in sublfolder. This is output.
[cporgs/apue/threads]: mkdir first
[cporgs/apue/threads]: ./a.out test.txt first
test.txt -- first/test.txt
dfdfdfdfdfdfdf-14
dfdfdfdfdfdfdf-14
in thread test.txt first
[cporgs/apue/threads]: cat first/test.txt
dfdfdfdfdfdfdffirst/test.txt
[cporgs/apue/threads]: cat test.txt
dfdfdfdfdfdfdf
I could not able to get from where this filename and folder is getting added.
Why this makefile only executes the first entry, compiling only the first program listed?
###########################################################
#
# Simple Makefile for Operating Systems Project 2
#
###########################################################
vowcon:
g++ -o vowcon vowcon.cpp -pthread
osproj2c:
g++ -o osproj2c osproj2c.cpp -pthread
osproj2b:
g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
gcc -o osproj2a osproj2a.c -pthread
clean:
rm osproj2a osproj2b osproj2c osproj2d vowcon
how I can run this as a separate process from the parent program, like a child process,
and return the result back to the parent program.
this script is as follows.
if file "/Stuff/s" exists then continue to run, if file "/Stuff/t" exists, then print "started" if file "/Stuff/t" does not exists, then print "stopped"
if file "/Stuff/s" does not exist then print "quit" and then quit.
Code:
void controlxmmscheck( ) {
if( access( "/Stuff/s", F_OK ) != -1 ) {
xmmscheck
} else {
[Code]....
I have this problem for an assignment, and one of the functions that I created for it is nothing fancy; just a function that'll take in a number and error-check to make sure the input is valid. However, after doing it, when the program calls that function, it skips the cin statement and ends the program, without letting the user input his number. The function in question is called getSubLength.
Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;
const string JANUARY = "January";
[code]...
in the below program for both class pointers pointing to null. Class contains normal function executing but class contains virtual function getting segmentation fault.
#include <cstdio>
using namespace std;
class A
{
[Code].....
We have been assigned to create a program that uses multiple functions. The professor has given us code for two of the functions, one to open a file and then another one to read the files contents and output them. I have put these into my program but they will not execute. The program does run, but the functions themselves are not executing. I have practiced with other functions that contain no parameters and those run fine, but the functions she gave us have multiple parameters.
The code I have so far is below:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
void PrintFile (string FileName, ifstream& inFile);
int main () {
ifstream inFile;
string fileName;
[Code] .....
I tried.
cin.get();
and
return 0;
is there a better way to keep the user info displaying without closing the console window.
PHP Code:
using namespace System;
ref class A {
public:
A(){Console::WriteLine(L"A constructor");}
virtual void func(){foo();}
void foo()
[Code] .....
Supposing that class A is the development code; and so for unit-testing purpose I create a mock for it. But I don't know how to override A's constructor such that it will not get executed in my unit-test code.
I am currently working on a c++ project that will input students and process their grades. I encountered a problem and my code stops executing after the getScores function. Im not sure what the problem is, but im guessing its something within the function and the loops.
//Name: getScores
//Description: Will get scores for student
//Parameters: None
//Return: testScore
double getScores()
[code]....
I have a Windows form application which has database and will store user details. my problem is while executing program form is not displaying .
View 1 Replies View RelatedIs there a way to tell the program to continue reading the next line of code within a nested IF statement?
The reason I want to do this is because the two "else" statements in the following sample (the main and the nested else) will contain the same exact code and I don't want to repeat it twice. I know I can do this by creating a function and calling it from each else statement but I was just wondering if what I'm asking is even possible without using a function.
if(1 < 2) {
// yes 1 is less than 2
if(5 > 10) {
// do something
} else {
// no, 5 in not greater than 10
// here is where I want to tell the program to continue reading the next else statement
[Code] ....
How do I play a simple mp3 through my mic. I plan on using this to just play annoying sounds through skype and games(on windows 7 btw).
View 6 Replies View RelatedSuppose you want to develop a program to play lottery. The program randomly generates a Lottery of a three-digit number( any number from 100 to 999), prompts the user to enter a three-digit number, and determines whether the user wins according to the following rule:
1. If the user matches the lottery in exact order , the awards is $100,000.
2. If the user input matches the lottery digits, the awards is $50,000.
3. If two digit in the user input matches a digit in the lottery, the awards is $30,000.
4. If one digit in the user input matches a digit in the lottery,
the awards is $10,000.
Sample:
The winning number is 865.
Your ticket is 865 then 100000
Your tickect is 686, or 568,.. all digits are right but not in order
You get 50000
Your ticket is 860, or 186 .. then 30000
Your ticket is 800, 706, 600.. just one digit much you get
10000
Else
0
Im using if/else statements. Which syntax would I use to figure out the limit between 100-99?
I have a Blackjack game that allows users to create a login account and it keeps track of their bet amount, and total bank,etc. How can I connect the program on 2 or more computers so that people can play together?
(A) How would I code it? (B) Can I just connect a USB or HDMI and use the appropriate code? (C) Do they need to be executables instead of just running out of Visual Studio? (D) Can this maybe done over Wi-fi? (E) Or is this something more complicated like over a VPN?