|
First i'd like to say thank you for the help. I get the TTL Signal via the Line In Port in my Computer and the data is is processed with an FFT Algorithmus that i found on the internet and i wanted to use the points the FFT returns, is it possible ?
|
|
|
|
|
Interesting. How in the world did you find a way to access the LineIn on a sound card? I didn't know that it was possible. Or is this some kind of analog to digital converter card you have? There is no such thing as a Line In "port" on a PC, but sound cards have audio input jacks by that name.
If you are accessing data that can be FFT'd you should be looking at digitized analog voltages. If you want to work with the raw data, you could scan the data for peaks followed by minimums, then pick an arbitrary point halfway between them to call the transition point. The number of samples between high-to-low transitions divided by the sample rate (#samples / samples per second) will yield the time between transitions.
Simpler, though, if you have the FFT data available, is to simply locate the peak value and determine its frequency. Since this is frequency domain data, the peak represents the fundamental frequency of the input signal. That corresponds exactly with the period you're trying to determine. Each data point in the FFT output array contains the magnitude of the input signal due to a frequency that is a multiple or submultiple of the sample rate. Locating the peak will be easy - in a square wave such as you've illustrated, the fundamental component is half the peak value, and since it contains only odd harmonics there will be much smaller peaks at 3f0, 5f0, 7f0, etc. The inverse of the frequency of the largest value in the array is the period of the signal.
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
Thanks for your help You are right im using the Line In Jack at my Soundcard not the port (sorry, but I'm from Germany). I think i gonna maybe write an article about this Topic. ^^
|
|
|
|
|
RedDragon2k wrote:
I think i gonna maybe write an article about this Topic.
Cool!
I'd love to know how to access the soundcard hardware. It's a handy device for its intended purpose, but it would be much more useful if we could easily use its A/D and D/A converters for other uses.
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
Hi all
I want to use coInitializeSecurity() in my program
i included objbase.h and define win32_DCom but
i got an error Undeclared Identifier .the same problem with coCreateInstanceEx() . but there isnot any error with coCreateInstance().
thank you
|
|
|
|
|
Hi,my class definement is as follows:
class A
{
public:
A(){cout<<"A::A()"<
|
|
|
|
|
i'm not sure of the output, but the first thing i see is that you derive A and its destructor (A::~A() ) is not declared as virtual ...
i think so the output is:
A::A()
A::A()
B::B()
A::~A()
A::~A()
is is wrong ? (i did not compile to test, so i may have written an error, but that was the game, wasn't it ? )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
bobi_zcl wrote:
what is the output result?why?
Why don't you step through it yourself and find out? Note that the code in main() won't work on VC7.x, the declarations of a and b will be treated as function prototypes, not variable declarations. If you use 7.x you'll need to change it to:
A a = A();
A b = B();
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
I have problem with running my application on PCs with pentium IV processors. On AMD processors it runs without problems. When I analyzed the problem, I have found that memcpy function probably does not behave correct. Is this some compiler bug (I am using MS Visual .NET 2001) or something like memory aligment fault? On pentium IV application crashes with "memory protection fault". If I well understand MS article "Windows data alignment" memory aligment cannot cause application crash on pentium IV, it can only cause worse performance, so it is not probably this kind of problem.
|
|
|
|
|
Is your application multi-threaded? If so it could be a race condition.
Most Pentium 4 processors use HyperThreading (HT) technology. These Pentium 4 processors are multi-cored processors. They will behave differently than on a single core processor like the AMD chip range.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
you are right, my application is multi-threaded. I use one thread for loading, this thread creates some data, which then the parent thread use. So if I load data in same thread as I will use them, then I solve the problem? Or is there some simple solution to conserve multi-threading and avoid this problem, some way to disable hyperthreading?
|
|
|
|
|
It would seem that you have a bug in your program that you need to fix. It is pure luck that you do not see it on AMD processors. Altering the environment may mask the problem on the machines you are able to test on though this is not a guaranteed solution in general.
From your description of what you are doing here are a few tips:
Your suggestion of loading the data into the thread that you are using it in is a good one. One thread accessing the data is always easiest.
When accessing data across threads there is need to ensure that only one thread can use the data at any one time (serialize data access). One way to achieve this is to use critical sections.
Do not allocate memory in one thread and clean it up in another. It is far easier to manage memory allocation / deallocation in the same thread.
If all else fails, there are many articles out there about multi-threaded applications programming. You will probably find a few here at CP.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I am using GD+ in my ActiveX Control. It Works. But TSTCON32.exe not removed from memory.It is still running even after i closed testContainer(TSTCON32) application. Please look at this simple code and tell me problem.
Here is the Code.It simply initialize in InitInstance and Shutdowns in ExitInstance.
AfxStd.h
/////
#if !defined(AFX_STDAFX_H__C2F7B03D_540F_42F2_B794_2FEF9ED71973__INCLUDED_)
#define AFX_STDAFX_H__C2F7B03D_540F_42F2_B794_2FEF9ED71973__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxctl.h> // MFC support for ActiveX Controls
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Comon Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")
// Delete the two includes below if you do not wish to use the MFC
// database classes
#include <afxdb.h> // MFC database classes
#include <afxdao.h> // MFC DAO database classes
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__C2F7B03D_540F_42F2
TestApp.H - Application class header file.
#if !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_)
#define AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// dfdsf.h : main header file for DFDSF.DLL
#if !defined( __AFXCTL_H__ )
#error include 'afxctl.h' before including this file
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CDfdsfApp : See dfdsf.cpp for implementation.
class CDfdsfApp : public COleControlModule
{
private:
GdiplusStartupInput gdiplusStartupInput; // GDI+ Object
ULONG_PTR gdiplusToken; // GDI+ Pointer
public:
BOOL InitInstance();
int ExitInstance();
};
extern const GUID CDECL _tlid;
extern const WORD _wVerMajor;
extern const WORD _wVerMinor;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED)
////////////////////////////
TestApp.Cpp - Applications cpp file
#if !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_)
#define AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// dfdsf.h : main header file for DFDSF.DLL
#if !defined( __AFXCTL_H__ )
#error include 'afxctl.h' before including this file
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CDfdsfApp : See dfdsf.cpp for implementation.
class CDfdsfApp : public COleControlModule
{
private:
GdiplusStartupInput gdiplusStartupInput; // GDI+ Object
ULONG_PTR gdiplusToken; // GDI+ Pointer
public:
BOOL InitInstance();
int ExitInstance();
};
extern const GUID CDECL _tlid;
extern const WORD _wVerMajor;
extern const WORD _wVerMinor;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED)
These are only files which has code related to GDI+. I used ActiveControl Wizard. And I added the code to StartUp GDI+ nad Shutdown GDI+. That's it. I did not write any other code.
|
|
|
|
|
im now doing digit recognition,but cant run at all,problems is exist..
i cant solve for the header file too,even look through example in textbook,hv same problem..
i understand the counting of MLP,but when apply into my coding,hv problem..how???
thanks for reply..
|
|
|
|
|
hi all,
suppose that I have a File Called "abc.mdf" in C Drive ..Now I want to copy it to another directry in "D" Drive ..
So How do I do it using C++?
Thanks in advance..
|
|
|
|
|
You can call Win32 API
CopyFile(
"C:\\abc.mdf", // name of an existing file
"D:\\abc.mdf", // name of new file
FALSE // operation if file exists
);
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
CopyFile() or SHFileOperation() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Is it possible to use XP's built-in text-to-speech functionality in a C++ or C# application, without requiring the user to install any speech redistributable?
|
|
|
|
|
Dear All
Who had worked with 3D Studio Max or programmed in OpenGL please helped me !
I want to create a program that can control an character to animate according to user's action. For example if user press key 'A' then the character kick, if press 'B' then character punch,etc. My idea is reading key frame chunks in 3DS file that contains the info about characte animation(.3ds) and process to animate character, but how can I do this ? I don't know.
I am using 3D Studio Max 7 and I don't know the format of 3DS file that export from 3D Studio Max 7, so if you know please help me.
If you know any source code of reading 3DS file (.3ds) and process to animate character in this 3ds file by OpenGL,please tell me .
Thanks a lot.
|
|
|
|
|
Doesn't the 3D Studio Max SDK include support for 3DS files?
|
|
|
|
|
Dear you
I just know that, 3D Studio Max can export it's '.max' file to .3ds file format. For example, if i have a file named 'myleg.max', this file ('myleg.max') contains the model of my leg ( include mesh info,material info,etc). 3D Studio Max can export 'myleg.max' to 'myleg.3ds' and now my program must read 'myleg.3ds' by C++,OpenGL for simulate my leg and animate my leg. Ofcourse, in 3D Studio Max, I have been animated 'myleg.max' so in 3D Studio Max IDE, I can play an animation about my leg based on 'myleg.max'.
But at the moment I don't know how to read 3DS file (.3ds) and create animation based on this file by VC++,OpenGL
Thanks and regards
|
|
|
|
|
There are several "interlocked" functions such as InterlockedIncrement. All these functions change the interlocked variable value. There is no "get" function to just look at the value. Does this mean that threads can use the variable with normal references as long as they do not change it?
The value of the variable could be learned using InterlockedExchangeAdd of zero, or InterlockedCompareExchange with the same comparand as the exchange value. These obviously have more overhead than simple access.
-Obi Wan 2
|
|
|
|
|
From MSDN:
Simple reads and writes to properly-aligned 32-bit variables are atomic.
...
The interlocked functions should be used to perform complex operations in an atomic manner.
So only the ops that would require more than one step to mod the value have an interlocked function.
Also (from MSDN),
Simple reads and writes to properly aligned 64-bit variables are atomic on 64-bit Windows. Reads and writes to 64-bit values are not guaranteed to be atomic on 32-bit Windows. Reads and writes to variables of other sizes are not guaranteed to be atomic on any platform.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I had read this, but in my view it is not completely clear.
cmk wrote:
From MSDN:
Simple reads and writes to properly-aligned 32-bit variables are atomic.
This suggests that one could set the value of a variable by normal means. If that was the case, why is there an "InterlockedExchange"? Of course that answer is that it changes two variables atomically.
Thanks for your answer. I am proceeding based on this being the fact. I was looking for some confirmation. I am sure you are aware that finding problems with interlocking in a complex application with many threads accessing common data is daunting.
-Obi Wan 2
|
|
|
|
|
InterlockedExchange(&v, 0) creates a memory barrier.
It forces any cached memory changes for a processor to be flushed to main memory and made visible to other processors.
For the same reason you may want to do an InterlockedExchangeAdd(&v, 0) to get the value of v, that is to create a memory barrier.
...cmk
Save the whales - collect the whole set
|
|
|
|