|
How dare you try and help this person with their icomprehensible request ? No wonder you got voted a 1...
</sarcasm>
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
How do you connect to the amplifier? Because you mentioned MSComm I assume you are using a serial connection - are you sure you have the correct serial settings for the amplifier?
You should be able to download a more capable terminal program that allows you to send ENQ (ASCII 5) commands. The amplifier cannot send you an analog value, it must send a response back through the same serial connection, and in this case will be displayed in your terminal program. Failing that, look through CodeProject for serial communication, and you will have to write a program to send the ENQ, and read the response.
Note: ENQ is nothing special, and there is no 'ASCII programming'. If you look at an ASCII table[^] you will see that ENQ is just the value 5.
|
|
|
|
|
I've never gotten a good answer out of anyone when I have inquired about the proper way to ensure that a file is included only once in a build. I also did not see anything in my thread search so I'll ask and hopefully get a reasonable answer.
In the below subset of code, I though the first set of instructions was to ensure that the header file would be included only once in a build. Then I thought, well what is the pragma once for then? According to the MSDN help, pragma once does the same thing. So when class wizards generate a class header file, why do they insert code that seems to serve duplicate purposes? Any ideas?
#if !defined(AFX_RETRYDLG_H__4A3C71B3_E316_48A5_B38E_7F3E778D47DD__INCLUDED_)
#define AFX_RETRYDLG_H__4A3C71B3_E316_48A5_B38E_7F3E778D47DD__INCLUDED_
//I've already used the previous #ifndef ... #endif to
//ensure the single inclusion of my class declaration.
//Why do I need this #pragma once on top of that?
#if _MSC_VER > 1000
#pragma once
#endif
//of course my class would be declared after the #pragma once statement.
class MyClass
{
MyClass();
~MyClass();
};
#endif // _MSC_VER > 1000
|
|
|
|
|
#pragma once is a microsoft only pragma, and in the example you show, it is useless ( i think ).
I usually remove it from generated code.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
The way i understand it (could be wrong) is that the #ifndef test prevents referential loops when the compiler is recursing through the #include lists for a given module. This is on a per module (cpp file) basis.
Where as the #pragma once is for the entire build session. It likely instructs the compiler to cache the parsed contents of the file so that the second module that needs the file doesn't have to reparse it.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Personally, I'd stay with the #if, etc. directives as this is a more portable way of doing things.
However, the reason for...
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif
...appearing is (IIRC) due to a bug with the developer studio debugger when keeping track of something or another. I tried googling to refresh my memory to no avail though.
Jeremy Falcon
|
|
|
|
|
When you use the #pragma once directive, the compiler will only open and read the file only once. If all you use is the #ifdef...#endif code block, then the compiler will open and read the file every time it is encountered, which is not all that efficient when all of the files contents gets ignored anyway. The only think to remember is that the #pragma once does not work on older compilers, so it is wise to always include both methods in your header file.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
thanks for the additional info, I think I read that before, but it's nice to have a reminder.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
One benefit not yet mentioned is that if you use the #ifdef method, you can test later to see if the header was included. For example WTL has this:
#ifndef __ATLBASE_H__
#error atlapp.h requires atlbase.h to be included first
#endif to check that atlbase.h is included before atlapp.h.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Four fonts walk into a bar. The bartender says "Hey - get out! We don't want your type in here."
|
|
|
|
|
I have an MFC dialog which has three property pages on them. All was well until I added a Menu at the top. The menu now covers most of the tabs for the property pages, and I cannot figure out how to move the property pages down. They are of type PP_LARGE.
Bob
|
|
|
|
|
I want to loop a segment of a wav file, but when I set the play cursor back there's a "blip" so I need to somehow put the portion of the wav I want to loop in a separate secondary buffer (because DirectSound only supports looping for an entire buffer), but then I don't know how to play the different buffers seemlessly. Do I use 3 buffers one for the "attack" one for the "sustain" and one for the "decay" portion of the wav or do I use one buffer and somehow stream the data into the buffer.
|
|
|
|
|
Use three buffers.
The primary buffer is used by DirectSound to playback the wave. You shovel data into this buffer, DirectSound then plays the data and then the data is discarded. You then have one secondary buffer that contains actual data from the file you wish to play. The easiest way is to use small wave files and load the entire file into this buffer. Finally, you have a tertiary buffer that contains only the data you wish to loop. If your sound files are large (over 1 Mb), the secondary buffer must be a streaming one or you'll quickly run out of memory.
While normal playback is up, shovel data from the secondary buffer into the primary buffer. When a looping section occurs, shovel data into the primary buffer from the tertiary one. When the looping should end
The most efficient way to do this is to create two wave files. One which has the entire wave you wish the play, and one with just the looping section. You can then use a full-feature wave editor program to accurately pinpoint the samples and timings on where you can start the loop, and where you can end it and continue with the original file.
It is wise to use a buffer. The alternative is that you shovel data directly from the file stream into the primary buffer. The disadvantage is that if a disk-excessive application happens to start or the OS needs access to the drive, your sound may glitch badly. Loading the data into a buffer beforehand is more efficient. Naturally, best results are achieved by using small buffers and always keeping a few seconds of audio data in reserve.
For an example on how to use a secondary buffer with DirectSound, you should consult the DirectSound C++ SDK and it's manual. The necessary functions (Lock, Unlock, Play) can be found from the IDirectSoundBuffer -interface.
I suggest you first design the buffer-usage with a paper and a pen, taking note of buffer positions, chunk sizes and all that. Remember that you can specify the size of the secondary buffer, but not for the primary one.
If this does not help you out, I might consider writing a small sample application, as the technique interests me as well.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I use 3 buffers now and I can loop the sustain portion of the sound seemlessly, however, now there's a "blip" before the start of the loop and at the "release", which is what I thought would happen. The first wav plays and at the end it signals for the next wav to play (the loop wav) but the sound of the 2nd wav doesn't start soon enough, causing the blip. When the 2nd wav stop playing and the 3rd wav is signaled to play there's another blip for the same reason.
So basically I need a way to seemlessly play one wav (in a buffer) after another. It seems the only way to do this is to implement some sort of overlap/switch between the 1st/2nd buffers (using GetCurrentPosition to see where to start playing in the 2nd buffer) and some sort of crossfade (for the release).
The WAV already has markers for loop start/end and release (which I use) and I have another program that can play the sound correctly so I know that glitchless play back is possible.
|
|
|
|
|
I tried to do an "overlap/switch" with the buffers, but it didn't work. I can't get the playback of the 2nd wave to start where the 1st wav left off (i.e. I can't connect them in playback without a blip). I'm sort of stuck...I might try to do it via streaming, but I don't know if that'll work (i.e. using only 1 buffer that plays/loops continuously with periodic writes to the beginning of the buffer to replace old data (until only the loop part is remaining).
|
|
|
|
|
This is precisely what I was talking about. In order to achieve smooth transition from one wave to another, use one secondary buffer in STREAMING mode. Put it to play back in looping mode, then showel in appropriate sound data from either the 1st wave, the 2nd, or the 3rd, depending on what you need.
The catch is to use some wave editor program to place markers or some other method to obtain precise moments in the sample files on where the looping section begins.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I haven't worked with audio for a while, but a "blip" when you loop is a natural hazard!
Even if you loop a complete WAV file, you will get a blip if the start and end do not have (1) the same value, (2) the same slope (i.e. the same rate of change of value), (3) the same rate of change of slope, etc.
Looping where start and end points have different values gives you a step in the waveform, which is heard as a click. Looping where the start and end levels are the same but there is a significant change in the slope of the waveform gives a similar, but less noticeable effect.
I forget the theoretical background - look at the Fourier transforms for a step function!
How much you hear a loop also depends on the grade of your sound card - a cheap card with poor frequency response may suppress the high frequency transient, making it less noticeable. But then again, it may not filter out high frequencies well, making the blip more noticeable.
Getting a smooth loop is an art (I never got this right - I hired a studio musician!)
Good luck.
|
|
|
|
|
winsock2 for MS Visual C++ Toolkit 2003
Do we need to find winsock2.h elsewhere?
Alternatively where do we access the following files please?
include sys/socket.h
include netinet/in.h
include arpa/inet.h
include unist.h
Can anybody help me please?
After downloading MS Visual C++ Toolkit 2003
My obective is to experiment with client server communications & eventually communicate over a network.
Do we need to find #include winsock2.h elsewhere?
and for example copy winsock2.h into the include directory of C:\Program Files\Microsoft Visual C++ Toolkit 2003\include.
I tried to compile the code in "IPv6-Enabled Client Code" in
MSDN Home>MSDN Library>Networking and Directory Services>Network Protocols>Windows Sockets 2>Using Winsock>IPv6 Guide for Windows Sockets Applications>Appendix B: IP-version Agnostic Source Code.
After selecting and copying the "IPv6-Enabled Client Code"
I pasted the resulting code into "notepad" and called and saved the new file as client.c.
I tried compiling the client.c using
C:\Program Files\Microsoft Visual C++ Toolkit 2003>cl /Tp client.c
The response was
Microsoft (R)32-bit C/C++ Optimization Compiler Version 13.10.3052 for 80x86
Copyright (C)Microsoft Corporation 1984-2002. All rights reserved
client.c
client.c(14) : fatal error C1083 : cannot open include file : 'winsock2.h' : No such file or directory
This ERROR REPORT has been changed
The previous reported error was incorrect because I forgot to remove a winsock2.h file from the include directory. I apologise this winsock2.h file DID NOT originate with the Microsoft Visual C++ Toolkit 2003 download or from Microsoft.
Yours sincerely,
George.
P.S. Alternatively where do we access the following files please?
include sys/socket.h
include netinet/in.h
include arpa/inet.h
include unist.h
|
|
|
|
|
include sys/socket.h
include netinet/in.h
include arpa/inet.h
include unist.h
I believe those are Unix style network header files and they don't exist in the Windows SDK.
Winsock2.h should be part of the Windows Platform SDK which is available for download or I beleive is installed as a default with Visual Studio 2003 C++
Can someone tell me what this reference to Visual C++ "Toolkit" is that people keep refering to?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi Pete,
Thank you for the advice.
I downloaded Microsoft Visual C++ Toolkit 2003
from
http://msdn.microsoft.com/visualc/vctoolkit2003
George Kermeen
george@dudley-designs.co.uk
george@kermeeng.fsnet.co.uk
|
|
|
|
|
I made a win32 dll and did these two things which BTW work for another dll I had made but maybe I have forgotten some step because this one gives: (also the earlier one took hours and hours before I got it to compile but it does now)
split.cpp(93) : error C2375: 'Split' : redefinition; different linkage
split.h(17) : see declaration of 'Split'
The lines in question are:
in the cpp file
#define DllExport __declspec( dllexport )
extern "C"
{
DllExport int __cdecl
Split (InputArgs inputArgs)
{
etc...
}
}
in the h file:
extern "C" int _cdecl Split (InputArgs inputArgs);
As far as I recall these are the only two things I had done in my other dll that works....but obviously I have forgotten something that makes that one work.
Any ideas appreciated.
thanks
sb
|
|
|
|
|
You need to add __declspec(dllexport) to Split() 's prototype in the header file.
Jeremy Falcon
|
|
|
|
|
I just built a simple database using CFormView. When I was completing the wizard I clicked for the form to start up minimized. After completing my project, I found myself wishing I had chosen to have it start maximized. How can I change this after I've finished? I'm new at this so take pity if it's just a simple change I need to make. Thanks!
Garry
|
|
|
|
|
Look in the InitInstance() method.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thank you, I checked InitInstance() and even InitApplication() and can't find anything that would possibly correct this. Any other thoughts? I really appreciate your guidence.
Thanks
Garry
|
|
|
|
|
I created an app that minimizes when it opens and this is what I found.
BOOL CMyApp::InitInstance()
{
...
...
...
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOWMINIMIZED);
m_pMainWnd->UpdateWindow();
return TRUE;
}
Change or add m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); to the above code.
|
|
|
|