When 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)...
I have a class which I wrote and one of its object is "SerialPort" .NET class. In my MainWindow I created instance of my class called "SerialPortComm", then I send through some functions of mine, commands to the Serial Port, and I receive answers through "DataReceived" event.
But when I trying to use Dispatcher.BeginInvoke to write my data I have received (successfully), nothing shows on the RichTextBox which I'm trying to write to.
What can caused that, and How I can make it works?
SerialPortComm.cs
public partial class SerialPortComm : UserControl { public SerialPort mySerialPort = new SerialPort(); public void Open_Port(string comNumber, int baudRate) { mySerialPort.PortName = comNumber; mySerialPort.BaudRate = baudRate;
16bit samples stored in shorts how i can reduce bits ? i meann idea not sources. i try learn code itself (i not school but i still dont want premade solutions for this)... i mean way make 16bit sample sound for example 4bit/8bit... and these are are audiosamples.
I need to average integer measuring samples and store this variable, so that it can`t be changed.
I need to get the initial pressure reading from my bmp085 pressure sensor, an integer value between 0 and 10000 and store the initial value after program start, so I can compare the later readings to determine whether pressure went down or up. The value to store should also be integer, rounding errors don`t matter.
When you press a key it automatically delays a bit then starts repeating without delay.
The second key pressed action comes with a delay and i want it to start repeating without delay. And could not find anything useful.
I might not be able to tell what i want exactly. Ok press simply a key and don't release it in a text editor. You will realize a delay at second character showing up.
int count = t1; while(count>counter){ Sleep(delay); Int32::TryParse(textBox2->Text,add); result = result + add; counter = counter + 1;
Problem is that sleep stops all program for specified time, Is there an alternative to sleep that would only stop part of code or can i use sleep different way to specify what it pauses?
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
So I'm in the process of building my 2D game in Allegro5, I'm building a side platform game and at the moment I have a sprite being able to walk left right and jump. What I want to do is put a time delay on the jump function so that when a user presses the jump button and the sprite has carried out the jump function I want there to be a 1 or so second delay before the jump button actually carries out the jump function again.
I have quite a bit of code so not sure what bits to place in here, I'm more looking for a way of doing this, so providing me code isnt really needed just a way it can be done.
Things that might be useful to know:
At the moment I have a timer initialized in allegro which is used with my FPS int to mean that my game runs at 60FPS.
I have a bool bIsOnGround which maybe could be used into this, I'm not sure...
I want to calculate the total some of delay pf receiving Side Packet . Code is as Follow ..
What is weird that even if i invoke a sleep of 2 sec ,than its show delay always zero. Delay will be in microsec ..Is there any problem with logic or anything else..
Code:
do {#pragma omp parallel private(nthreads, tid) { /* Obtain thread number */ tid = omp_get_thread_num(); if (tid == 0) { nthreads = omp_get_num_threads();
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:
cout<<"1. runtim"; cout<<"2.tims"; cout<<"Your selection will be automatically neglected within (function to be inserted for time ) ";/* insert timer here */ cout<<"What kind of process u need to do"; . . . .
I have 2 questions
1.the timer function has to be such that when any key is pressed in between the specified time its has to stop its counting and go to the nest line and functions . i checked sleep function but if any key is pressed its does not break out of the sleep program and execute the next command
2.and if the timer has completely finished running then it has to skip few lines and execute the program .
I have the following code below. I am getting a memory access violation when accessing cmd->query_string in the loop function. The loop() function is running in another thread. The cmd object appears to be destroyed after calling the send_command function. How do I create an object on the heap and access the query_string.
I was working on a problem that was best solved with chaining threads together using a blocking thread-safe queue. Eg threads A and B pass data to each other using a queue ... a simple producer consumer design A -> B. This has two benefits: 1) being that there is a buffer between the two threads to cache for a slow consumer and 2) allows for better throughput when loads of data are high because the two can run in parallel. Most of the time the design works well under load. but I found when pushing data through the threads intermittently, i.e. once about 0.5 seconds it ran poorly, mostly from what seemed to be latency introduced during the OS waking up of the consumer thread B.
What i have come up with to solve this issue is what i call an .... Its a wrapper around a basic thread safe queue and adds one extra function called .... The idea here is that if you have a simple case (or perhaps a slightly more complicated case) of two threads in a prod cons design and you know the producer will create or received the data, process it, and then push onto the queue, why not give the consumer thread a heads up to let it know the data is about to arrive. In this case call .... In this way you can have the consumer thread in a polling state anticipating the arrival of data and avoid the time to schedule it back to a running state.
Anyway, i have some code below and I was looking to get some feedback. I have tested it somewhat and it does improve the responsiveness quite substantially.
progd->count was devised to stop the thread when the recursion ended by posting a message to the main window. When it reaches 1, the def procedure sends the WMU_DISC_DONE message to set the event
All that *appears* to work; however, if I cancel the recursion thread, the list view continues to populate for a bit and then deletels all but 1 item though I send the message LVM_DELETEALLITEMS.
If I move the (tmp->canceled == TRUE) test inside of the do-while, the app gets loopy.