|
That depends on the relationship between the two signals. Are they partially overlapped, sequential with a fixed or variable delay between them, or sequential with no delay (first sample of a given stream is one sample after the last sample of the prior stream)?
|
|
|
|
|
It's most close to the "partially overlapped" signals ..
so what can you propose to me ?
thanks
|
|
|
|
|
The answer is simple, but I don't want to lead you down the wrong path. More information is needed to determine the correct solution. When you say it's "most close" to partially overlapped, what do you mean? You said this is DSP, so I assume that you're receiving chunks of buffer from an input source. If that is the case, you shouldn't need to worry about overlap or delay between the buffers, and a blunt join of the buffers would be appropriate and wouldn't cause a pop in the audio stream since the two buffers are chunks of a uniform stream. If you have two audio files from independent sources which you wish to connect, or wish to transition from one live audio source to another while receiving data streams from both, then do a linear crossfade as Tim Smith indicated. At the beginning of the fade, the audio source to be faded out is at full volume, the one to be faded in is at zero volume. At the midpoint of the fade, each audio source is at half-volume. At the end of the fade, the one fading out is at zero volume and the one fading in is at full volume. The multipliers go from 1.0 to 0.0 and from 0.0 to 1.0 linearally. Just multiple each sample across the fade by the multiplier for that buffer, and add it to the sample from the other buffer times its multiplier. At each sample, the sum of the two multipliers is 1.0 (full volume).
|
|
|
|
|
I wouldn't worry about it. A 44khz sample rate is trying to handle signals up to 20khz. At 20khz there aren't going to be many samples per complete wave. If you wanted to, you could do a linear interpolation between the two signals for maybe 2-4 samples. That would be plenty of sample and should eliminate any "click".
But then again, I am talking out of my arse.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Well , but what about interpolation ?
How can i implement it ?
And how can i eliminate "clicks" ?
regards
|
|
|
|
|
A click is the sudden change in value for the signal. For example, going from 0 to 65535 for a 16 bit signal.
A linear interpolation example would be:
Last sample for signal a = 20.
First sample for signal b = 220.
To interpolate between the two samples using 4 new samples, you would insert the new samples between the two waves.
60,100,140,180
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
How can I get the IP address of a url? I been using gethostbyaddress but it keeps returning WS_NODATA (even on cp, msdn.microsoft.com ...)
BTW (m_locSite=GetLocationURL()):
if (m_locSite.Find("file://",0)==-1)<br />
{<br />
m_locSite=m_locSite.Mid(0,m_locSite.Find("/",8));<br />
if (m_locSite.Find("://",0)==-1) m_locSite="http://"+m_locSite;<br />
<br />
WSADATA wsa;<br />
WSAStartup( 0x0101, &wsa );<br />
unsigned long addr = inet_addr(ConvertCStringToChar(m_locSite));<br />
<br />
if (addr == INADDR_NONE)<br />
{<br />
<br />
HOSTENT * lpHostEnt = gethostbyname(ConvertCStringToChar(m_locSite));<br />
CString tmpEr;<br />
tmpEr.Format("%d",WSAGetLastError());<br />
MessageBox(m_locSite+" | "+tmpEr);<br />
<br />
if (lpHostEnt)MessageBox(inet_ntoa( *(LPIN_ADDR)*(lpHostEnt->h_addr_list) ));<br />
<br />
<br />
}<br />
WSACleanup();<br />
}
-Steven
CP Addict
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
Rather than adding the http:// if not present, I believe you should strip it off if it is, and content after any subsequent slash (including the slash should be stripped. For example, given a url http://www.codeproject.com/script, the actual host name is www.codeproject.com.
|
|
|
|
|
THANKS ALOT!!!!
It was really bugging me.
-Steven
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
THANKS ALOT!!!!
It was really bugging me.
-Steven
CP Addict
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
..Do you know what function retrieves all the text of a MS Word document via automation in VC++? Thanks in advance for saving me an hour and half of searching on MSDN!
|
|
|
|
|
There's a Delphi sample in SoftMosis Delphi/MSWord Automation FAQ[^]. It's done via the IDataObject interface.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How can i get an image (for example 100x100) under curent position of mouse pointer ?
|
|
|
|
|
|
Is it possible to set tab stops with a list view control in report mode as can be done with a list box, akin to LBS_USETABSTOPS?
If the answer to the above is no, let me explain what I'm trying to accomplish and I would welcome suggestions as to what would be a better approach. The application I'm working on has a live display of commands, events, and data packets to and from a hardware device. It can also write a log file with that information. The user needs to be able to open that log file and view it in a variation on the live log window. The log file can grow to be arbitrarily large. The log file is parsed once to determine a "packet" count and line count, and then a virtual list control is created (LVS_OWNERDATA). The log file is subsequently re-parsed on demand to cache a range of packets around the current view position. The user can enable and disable details display on all packets. Without details, the list would lend itself well to columns, but with details display, it wouldn't, since the details need to be formatted as:
1/1/03 9:39:59.321____usb_____Command___Reset
____Data = [03 0C 00]
1/1/03 9:39:59.321____usb_____Event______Command Complete
____Data = [0E 04]: 01 03 0C 00
____Num_HCI_Command_Packets = 0x01
____Command_Opcode = 0xC03 ("Reset")
____Status = 0x00 ("Success")
____^______________^_______^_________^
The packet header lines need to be column-aligned, but the details, when shown, run across column boundaries. Therefore, I need the list control to have a single column, but use tab stops to align the fields at the positions indicated with carets.
So...should I switch to a list box with owner draw style to avoid bringing all of the packets into memory instead? Ideally, I'd like to stick with a list view control and somehow get it to respect tabs instead of just showing a
box character.
Thanks in advance,
Brian
|
|
|
|
|
|
Thanks, but I'm trying to avoid a fully customized control. I can do what I need to if I switch to list box instead of list view and take advantage of the owner draw property to manage which packets are cached in memory and when to fetch them from disk. I'd like to stick with the list view though so I don't have to reinvent the wheel in terms of the having to render everything. I'd prefer to let the system-provided controls just do their job. Unfortunately, if the list view really doesn't support tabs (a huge oversight on microsoft's part IMHO) I'll have no choice. Still hoping someone knows how to get the list view control to respect tabs...
|
|
|
|
|
Well, no. The list view control supports columns. The list control supports tabs. That's about the size of it.
You *can* use custom draw and the header control to implement columns on a list control, or custom draw and a bit of creativity to implement tabs on a list view control.
I'd put the choice at this: if you need columns, and you don't need variable-height rows, go with the list control. If you need variable-height rows, you'll need either a completely custom control or a customized list control.
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
I don't even need the columns per se. I need a column effect to lend readability to the packet display without details. But I need to cross multiple columns for the detail lines. That would suggest that the list box control with LBS_USETABSTOPS is the way to go. Problem is there could potentially be way too much content. I wanted to take advantage of the explicitly intended virtual property of the list view control and the ease-of-use of the API to add an icon to the heading lines (better visual cues for each packet to further enhance readability). But if it ties my hands in terms of the columns and won't do tabs (I was intending to use the list view control with a single column and tabs to provide alignment) then I may be out of luck and have to go with an owner-draw list box. I didn't want to have to go that far in the interest of time. If I could forget the icons and go with a list box instead of list view control, I still need the "virtual" property. Looking at the documentation, it sounds like I need the LBS_OWNERDRAWFIXED property. Unless it's there under layers of documentation silt, I don't see anything about being able to leave off the LBS_HASSTRINGS property, but also not use the LBS_OWNERDRAWFIXED property, let the list box take care of the rendering and I provide the strings on demand by a callback as with a virtual list view control. Is that possible? The documentation would suggest not: "By default, all list boxes except owner-drawn list boxes have this style. You can create an owner-drawn list box either with or without this style."
|
|
|
|
|
List boxes weren't meant to be used in the same way that list views were, and so "virtual" support is somewhat lacking. You *can* avoid string storage, but you still need to add items one-by-one and manually handle drawing and measuring them.
List views are *fairly* easy to use, and when drawing them yourself you can optionally ignore columns when you want to... but you can't have variable height items - whatever height you decide on, that's what it's gonna be for them all.
So if your plan calls for each item being two lines, the first tab separated and the second free-form, go with the list view. If you're gonna need more/less than two lines per item depending on content, go with either list box or completely custom control.
As far as raw speed goes, you really can't do better than a completely custom control, written to your exact needs. But these *do* take time to write and maintain... in the end, you need to decide whether it's worth it or not.
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
Hey I really appreciate all of your input. One last question and I think I'll have all the answers I need to move forward. You said "List views are *fairly* easy to use, and when drawing them yourself you can optionally ignore columns when you want to." How do you draw them yourself? The "List View Controls" section of the documentation in MSDN library makes no mention of it: the documentation deals solely with the API for using the built-in functionality. I see no mention of anything akin to WM_DRAWITEM for list boxes as pertains to list view controls. And that page, which I found by pure luck, naturally doesn't have any sort of up or next links to try to find documentation on the owner-draw functionality you said exists... If you can point me to the right section of the documentation (preferrably a URL in the MSDN web pages) that should suffice...
By the way, fixed height is perfect for this implementation. The design is that I have a total packet count, a range of cached packets, a detail line count for pre-cached packets, and a detail line count for post-cached packets. With details turned off, I set the item count to packet count, with details turned on, I set the item count to total line count. Wherever the view sits, I have the packets cached and provide via callbacks the text for each line (heading lines only with details off, heading lines interleaved with detail lines with details on). Instead, I'll need to draw the lines myself. So...where is it documented how to do that, or can you give me a constant that I can use as a keyword in a search (like LBS_OWNERDRAWFIXED, but it's cousin for list view controls).
Thanks again,
Brian
|
|
|
|
|
Brian Tietz wrote:
So...where is it documented how to do that
Why, on CP of course!
http://www.codeproject.com/listctrl/lvcustomdraw.asp[^]
(yeah, ok - it's in MSDN too, but there it's confusing and wrong)
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
In what is turning out to be a nightmare, I've been handed a project that has been pushed off for 5+ years.
My company has a large (500000+ line) legacy product that now needs to have full multilanguage features added. I've figured out the basic part of the work, changing the display code and refactoring the database, but I'm running into an issue with the sheer volume of possible problems within the functional part of the code.
For instance, all uses of isdigit, tolower, toupper, atol, isalpha, etc. all have to be looked out and replaced with their wide character versions when required. While tedious, this is doable. The problem is needing to flag things like this:
// Just a quick example
int foobar( char* foo)
{
if ((strlen(foo) >= 10) && (foo[0] >= '2'))
{
// entry won't fit in an int, raise error
}
else
return atoi(foobar);
}
Obviously changing the char to wchar_t, strlen and atoi functions isn't enough, but I'm hoping someone knows of software that might help flag these questionable constructs so that at least some of the need for visually inspecting all of the code can be minimized.
I may take a shot at writing an parser & analysis tool for this task, a week spent on the tool may save me time if nobody knows of anything available. Commercial or free, doesn't matter at this point...
|
|
|
|
|
I'm not sure of any tools that do this, but I had thought of writing one a couple months ago, when faced with a similar situation. It turned out that it wasn't even that hard to transform the project I was working on, but it wasn't a 500KLOC project either.
I think it would probably take about 1 day to write a really really simple lexer, and a pretty simple parser to take care of this situation for you. And it could probably chew through 500KLOC in a minute or two. Think about how simple it is to replace "char" with "TCHAR", and "strlen" with "_tcslen", and a simple character string "'a'", with "_T('a')"?. I know, since I've done the conversion, that there are a lot of cases, but I still don't think it would take that long to write the lexer/parser to do it.
At any rate, good luck.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
I have a basic Dialog Application .
After the MFC wizard exits after creating the classes i do the following :
1. Add ATL support to my project that adds the InitATl code to the App class TEST : Code compiles and Dialog displays !
2. Include the definition
#define _WIN32_WINNT 0x0400 to the Stdafx.h file to support Mulithreaded COM .because the InitATl function performs the following :
#if _WIN32_WINNT >= 0x0400<br />
HRESULT hRes = CoInitializeEx(NULL,COINIT_MULTITHREADED);<br />
#else<br />
HRESULT hRes = CoInitialize(NULL);<br />
#endif
TEST : Code Compiles and runs
3. Now if I add an Active X Control on the Dialog say a Microsoft Flexgrid Control .
TEST : Code Compiles and doesnt run .
DEBUG reports the following
Warning: OleInitialize returned scode = RPC_E_CHANGED_MODE ($80010106).<br />
Warning: CreateDlgControls failed during dialog init.
I am not able to figure out where I am going wrong and why the code does not run ? Please help (
|
|
|
|
|