C :: How To Handle Sound And Music Files
Mar 11, 2013I do not know any of the functions to do this, and when I looked on the internet all the functions I saw were mainly non-standard.
View 12 RepliesI do not know any of the functions to do this, and when I looked on the internet all the functions I saw were mainly non-standard.
View 12 RepliesThe music that I want to plays not run :( Theoretically all arguments are well, but I don't understand why not works.
if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) < 0) {
cout << "Error inesperado";
return 0;
}
Mix_Init(0);
Mix_Music *musica = NULL;
musica = Mix_LoadMUS("pixeluniverse.wav");
if (!Mix_PlayMusic(musica, -1)) {
cout << "Error inesperado";
}
...
i am working on a wav file and attempting to make it fade in and fade out but i am lost at the momment.. Check my coding below.
Code: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main ()
[Code].....
I want to make my computer beep, when a specific file I have already created changes. The idea is this:
I have a personalized e-mail for my website.
When people send me a message, I don't know what happens at all, but at least I can create a file which leaves the comment there. How can I make a program to beep when a file changes?
I code login form. In the textbox I want to clear if there are some text or close form if there's nothing. The problem is System beep sound occured when the text is cleared. Here's my code
private void tbPassword_TextChanged(object sender, EventArgs e)
{
string _enteredPassword;
while (tbPassword.TextLength == 8)
[Code]....
write a program, pfpq.c, that maintains a priority queue of music tracks (songs) and ratings. The struct is given by:
Code:
struct track
{
char artist[20];
char title[20];
int rating;
};
The program is only designed to demonstrate the concept so get the user to enter a small number of tracks and create a priority queue. (Use an empty string title or an empty string artist to end the program). Print the priority queue as it grows. Your program should initially ask the user if they wish to order the priority queue by rating in ascending order, or by rating in descending order, or if they wish to order the priority queue by artist name. Then build the priority queue accordingly. in the last case, "if they wish to order the priority queue by artist name." which is case 3. How do I sort the priority queue by artist name using in the following code.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pqueue.h"
struct track
{
char artist[20];
char title[20];
int rating;
}
[code]....
How can I play sound when the program ends? I am using Windows 7.
View 15 Replies View RelatedWhen I use the following handler to handle and mix multiple channels, I get about 1 time unit sound, 5/6 time units silence.
//The volume conversion!
#define VOLUME_PER_SOUND(volume) ((SDL_MIX_MAXVOLUME / 2)*volume)
//Ammount of times to multiply the buffer!
#define MULTIPLIER_BUFFER 1
/* This function is called by SDL whenever the sound card needs more samples to play. It might be called from a separate thread, so we should be careful what we touch. */
void SDLAudioCallback(void *user_data, Uint8 *audio, int length) {
[code]....
(I'm working with 44.1kHz stereo PCM streams)... I've multiplied the stream some times, but to no effect (see the c<MULTIPLIER_BUFFER loop arround the mixing)...
How does one go about Playing a music file that they picked and playing it in the default player?
I already have this:
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
string wavfile = "C:Documents and SettingsJasonMy DocumentsJasonMy MusicDummy.wav";
[Code] ....
I can not get the sound to stop playing a cda file with MCI_CLOSE. This code works with wav and mpg and avi files.
LONG WindowProc() {
switch (msg) {
case WM_COMMAND:
if (wParam == IDC_PLAY) {
//A CDA File
SendMessage(m_hwMCI,MCIWNDM_OPENA,0,(LPARAM)&chFile);
[Code] .....
I am writing a music program that will read (from a separate file) a guitar chord and display it to the the user. The format of the separate text file is as follows:
A
|--0--|
|--2--|
|--2--|
|--2--|
|--0--|
|--x--|
B
|--2--|
|--4--|
|--4--|
|--4--|
|--2--|
|--x--|
C
|--0--|
|--1--|
|--0--|
|--2--|
|--3--|
|--3--|
etc...
I want the user to be able to search for a specific chord in the file and how I can make that happen.
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
[Code] .....
I'm making an apllication which needs to play .wav file when user type something inside QTextEdit. I made some code but after minute or less the sound stops, so I made silly workarround. After 30 clicks I invoke sound->stop(); and then the loop start again, that works, but it's not good, can you give better solution. Here is my code:
Code:
int count = 0;
bool MainWindow::eventFilter(QObject *o, QEvent *e){
if(e->type() == QEvent::KeyPress)
{
tipka->play();
tipka->seek(0);
[Code]...
Let's say I want to calculate something like PI using some algorithm, but with the number of digits I want to.
View 1 Replies View RelatedConsider the following code which closes an overlapped I/O serial handle during application shutdown.
Code:
Win32Com.CancelIo(hPort);
Win32Com.CloseHandle(hPort);
It works fine under .NET 2.0 but after switching to .NET 4.0 it crashes on the CloseHandle. Removing CancelIO doesn't work.
What the correct way is to close an overlapped I/O handle? And why is there the difference between NET2.0 and 4.0?
How to handle cmd line argument in c.
View 5 Replies View RelatedI've been thinking over this for long time... For example, when a button is clicked, print a string "clicked" after 5 seconds. (the button won't be blocked)
Thread should be the only way to do this:
btn.on_click = []() {
thread thrd([]() { sleep_5_seconds(); cout << "clicked" << endl; });
thrd.start();
};
the local variable thrd is destructed right after it starts, which may cause a crash, so use new operator:
btn.on_click = []() {
thread* thrd = new thread([]() { sleep_5_seconds << "clicked" << endl; });
thrd->start();
};
The thrd never get deleted
How would you solve problem like this?
If a class A contains an array of objects of another class B.. And in the constructor of A, while constructing objects of B, any one object throws an exception, then how can we guarantee to release all the memory acquired.. so that there is no memory leak..
class B{};
class A{
public:
B Array[100];
...
};
In the above code, if in constructor of A, suppose 99 objects of B are constructed successfully, but 100th object throws exception, then how can we guarantee to release all the memory acquired by the other 99 objects?
I have a game that I'm trying to create but I don't really know how to handle mouse motions yet. I have read the LazyFoo.net lesson 9. And I have too searched around on Google but haven't find any good article for what I want to do
But what I want is to check if the mouse is OVER the START button of the game and if the user has pressed the LEFT mouse button the game should START.
This works when I am hovering over the area there I want the mouse to do something:
Code:
else if (event.type == SDL_MOUSEMOTION)
{
if (event.motion.x == 0)
{
quit = true;
}
}
I do not know how to check this. The START and QUIT button is in the middle of the screen and I don't know how to position the mouse there either.
I am using SDL 2.0. But I don't know how to handle mouse input. Do you think you can explain of how to do that? Or give me a link that explains that really great?
I know how to handle a mouse button that presses down for a sec.
Code:
if (event.type == SDL_MOUSEBUTTONDOWN){
if (event.button.button == SDL_BUTTON_LEFT){
// Do something . . .
}
}
But not how to handle the mouse input of what the mouse is hovering over and that.
Like in a start menu of a game. I want a button for example to appear blue when I hover over it and when I click on it. It should start the game for example.
I have an application that uses an array of threads to call a method along with thread.join(). I was just wondering what would be the best way to handle the thread in case if one of the thread fails? Should I put a try catch block on the method that is being called or should I put the try catch block on the array of threads, or is there any other proper way to handle failed threads?
View 3 Replies View RelatedAnd it is not running successfully... abnormal termination
View 3 Replies View RelatedI write a small application and using the following API to open the file:
hHandle = CreateFile(lpszFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
Then I pass the hHandle to a DLL exported function, in that function, I will call
DWORD dwFlags = 0;
ASSERT(GetHandleInformation(hFile,&dwFlags) != 0)
to check if the handle is valid. However, the assert fails. And I use GetLastError to get the error code 6, which means invalid handle.
What is the problem with my codes?
Visual C++ 2010
I'm using SFML with Visual C++ and need to pass a handle to a function. I've tried to find this on the web with no luck.
The handle happens to be a sprite defined as: sf::Sprite Numbers(MyNumbers);
Now I want to pass "Numbers" to a function.
-
-
getFrame(Numbers);
-
-
???? getFrame(??????) {
Numbers.SetSubRect(sf::IntRect(0,0,63,63));
return ????
}
How do I do this?
Here is an example,
Code:
int main()
{
try{
int y = 0;
int x = 2/y;
}
catch(...)
{
cout<<"catch it"<<endl;
}
return 0;
}
If you try, you will find out that catch(...) couldn't catch exception divided by zero. How'd we catch such exceptions?
I have an MFC program created from the app wizard. It is an MDI program, reading/writing text files using Serialize. I can read the document and know that the entire document was read into my buffer without any errors. This was verified by compaing the number of bytes read with the file length.
How do I get the document to display in my main/child window?
How do I read the document from the window so I can save it back to the file?
As we know in C there is no checking if values passed to a function that takes enum are correct, that is if they have been defined in this enum. Example from Enums in C | Occasionally sane ([code] tags don't work on my fx 18.0.1 this is why I put in on pb): [URL] ......
Here c - How to check if an enum variable is valid? - Stack Overflow they say that common convention is add check whether value passed as the parameter is not bigger than the maximum value in enum. But how about situations when enum is composed of numbers from 1-20 and then from 500-510?