Spraak Herkening (stand alone)

Status
Niet open voor verdere reacties.

mirrormen

Nieuwe gebruiker
Lid geworden
9 apr 2009
Berichten
4
Beste Mensen

Heb hier onder code geplaats met debug report die ik gebruik in Microsoft Visual Studio 6.0 Helaas heb ik een paar foutjes kan iemand mij helpen of heeft iemand suggesties dan hoor ik dat graag.

Code:
DEBUG Report
------------------------
Deleting intermediate files and output files for project 'Sr - Win32 Debug'.
--------------------Configuration: Sr - Win32 Debug--------------------
Compiling resources...
Compiling...
Sr.cpp
y:\data map\development\application\multiplatform\development c & c++\sr\sr.cpp(11) : fatal error C1083: Cannot open precompiled header file: 'Debug/Sr.pch': No such file or directory
Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\Sr.sbr': No such file or directory
Error executing bscmake.exe.

Sr.exe - 2 error(s), 0 warning(s)

 


// CPP Files
// MainFrm.cpp : implementation of the CMainFrame class


#include "stdafx.h"
#include "Sr.h"

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers




// SrDoc.cpp : implementation of the CSrDoc class
//

#include "stdafx.h"
#include "Sr.h"

#include "SrDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSrDoc

IMPLEMENT_DYNCREATE(CSrDoc, CDocument)

BEGIN_MESSAGE_MAP(CSrDoc, CDocument)
	//{{AFX_MSG_MAP(CSrDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSrDoc construction/destruction

CSrDoc::CSrDoc()
{
	// TODO: add one-time construction code here

}

CSrDoc::~CSrDoc()
{
}

BOOL CSrDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CSrDoc serialization

void CSrDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CSrDoc diagnostics

#ifdef _DEBUG
void CSrDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CSrDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSrDoc commands

// SrView.cpp : implementation of the CSrView class
//

#include "stdafx.h"
#include "Sr.h"

#include "SrDoc.h"
#include "SrView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSrView

IMPLEMENT_DYNCREATE(CSrView, CView)

BEGIN_MESSAGE_MAP(CSrView, CView)
	//{{AFX_MSG_MAP(CSrView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSrView construction/destruction

CSrView::CSrView()
{
	// TODO: add construction code here

}

CSrView::~CSrView()
{
}

BOOL CSrView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CSrView drawing

void CSrView::OnDraw(CDC* pDC)
{
	CSrDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CSrView printing

BOOL CSrView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CSrView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CSrView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CSrView diagnostics

#ifdef _DEBUG
void CSrView::AssertValid() const
{
	CView::AssertValid();
}

void CSrView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CSrDoc* CSrView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSrDoc)));
	return (CSrDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSrView message handlers


// stdafx.cpp : source file that includes just the standard includes
//	Sr.pch will be the pre-compiled header
//	stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"





#ifdef GCCmod
	#include "traps.h"
#else
	#ifndef WORKSTATION
		#define WORKSTATION
	#endif
#endif

#ifdef WORKSTATION
#ifdef WIN32
#include "StdAfx.h"
#endif
#include <math.h>
#include <stdio.h>
#include <assert.h>
#pragma warning(disable : 4005)
#endif


#define NSAMPLES_PER_INTERVAL 250
#define NSAMPLES 4000
#define NDIM     80
#define NWORDS   5

float Buffer[NSAMPLES];
float word[NDIM];
float dic[NWORDS][NDIM];

void initialize();
void get_sample();
void analyze( float *, float * );
int  lookup( float[][NDIM], float * );
void control( int, int );
float euclidean( float *a, float *b, int length );

float filter1( float x );
float filter2( float x );
float filter3( float x );
float filter4( float x );
float filter5( float x );

void main()
{
	int i, j;
#ifdef WORKSTATION
	float max;
#endif

	initialize(); // open files (if testing on workstation), 
				  // initialize interrupts (if on UltraGizmo board)

	for( i=0; i<NWORDS; i++ ) {
		get_sample(); // read in a word sample (assume framing is done by low level routine)
		analyze( Buffer, dic[i] );

#ifdef WORKSTATION
		max = 0.0f;
		for( j=0; j < NDIM; j++ ) {
			if( dic[i][j] > max ) max = dic[i][j];	
		}
		printf("word %d max = %f\n", i, max );
#endif
	}

	for( i=0; i<NWORDS; i++ ) {
		int command = -1;
		// assume keyboard i/o is used to interrupt this loop
		get_sample();
		analyze( Buffer, word );
#ifdef WORKSTATION
		printf( "doing recognition on test vector %d...\n", i );
#endif
		command = lookup( dic, word ); 
		control( command, i );
#ifdef WORKSTATION
		printf( "\n" );
#endif
	}
}

////////////////////////////////////////////////////////////////////////////////
//
#ifdef WORKSTATION
FILE *g_infile;
void initialize()
{
	g_infile = fopen( "Train.dat", "r" );
	assert( g_infile );
}
#else
void initialize() { }
#endif

////////////////////////////////////////////////////////////////////////////////


void get_sample()
{
#ifdef WORKSTATION
	int i;
	for( i=0; i < 4000; i++ ) {
		fscanf( g_infile, "%g\n", Buffer+i );
	}
#endif
#ifdef GCCmod
	input_dsp( Buffer, NSAMPLES, 0 );
#endif
}

////////////////////////////////////////////////////////////////////////////////


void analyze( float *sample, float *fingerprint )
{
	int i, k, x;
	k = 0;
	for( i=0; i < NSAMPLES; i+= NSAMPLES_PER_INTERVAL ) {
		int j;
		double y1=0.0f, y2=0.0f, y3=0.0f, y4=0.0f, y5=0.0f;
		double m;

		for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
			float y = filter1( sample[i+j] );
			y1 += y*y;
		}
		m = frexp(y1+1, &x);
		fingerprint[k++] = x+m;

		for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
			float y = filter2( sample[i+j] );
			y2 += y*y;
		}
		m = frexp(y2+1, &x);
		fingerprint[k++] = x+m;

		for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
			float y = filter3( sample[i+j] );
			y3 += y*y;
		}
		m = frexp(y3+1, &x);
		fingerprint[k++] = x+m;

		for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
			float y = filter4( sample[i+j] );
			y4 += y*y;
		}
		m = frexp(y4+1, &x);
		fingerprint[k++] = x+m;

		for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
			float y = filter5( sample[i+j] );
			y5 += y*y;
		}
		m = frexp(y5+1, &x);
		fingerprint[k++] = x+m;
	}
}

int lookup( float dic[][NDIM], float *word )
{
	int result, i;
	float min = 0;

	// by default assume the first word... 
	result = 0;
	min = euclidean( dic[0], word, NDIM );
#ifdef WORKSTATION
	printf( "distance 0 = %g\n", min );
#endif
	for( i=1; i < NWORDS; i++ ) {
		float tmp;
		tmp = euclidean( dic[i], word, NDIM );
#ifdef WORKSTATION
		printf( "distance %d = %g\n", i, tmp );
#endif
		if( tmp < min ) {
			min = tmp;
			result = i;
		}
	}
	return result;
}

float euclidean( float *a, float *b, int length )
{
	int i;
	float result=0.0f;
	for( i=0; i < length; i++ ) {
		float tmp = a[i]-b[i];
		result += tmp*tmp;
	}
	return result;
}


////////////////////////////////////////////////////////////////////////////////

void control( int command, int i )
{
#ifdef WORKSTATION 
		printf("word %d was recognized as word %d\n", i, command );
#endif
#ifdef GCCmod
	output_dsp( &command, 1, 1 );
#endif
}

#define A11 -1.42116311276060f
#define A21  0.51814706507531f
#define B01	 0.05114107979340f
#define B11	-0.01658864464707f
#define B21  0.05114107979340f

#define A12	-1.70960095672886f
#define A22  0.80456561825031f
#define B02  2.51696834558782f
#define B12 -3.92574709726961f
#define B22  2.51696834558782f

#define G 0.09698395231471f

float filter1( float x ) 
{ 
	static float d01 = 0.0;
	static float d11 = 0.0;
	static float d02 = 0.0;
	static float d12 = 0.0;
	float y1, y2, t0, t1;

	/* first 2nd-order filter stage */
	t0 = x - A11*d01 - A21*d11;
	y1 = B01*t0 + B11*d01 + B21*d11;
	d11 = d01;
	d01 = t0;
	/* second 2nd-order filter stage */
	t1 = y1 - A12*d02 - A22*d12;
	y2 = B02*t1 + B12*d02 + B21*d12;
	d12 = d02;
	d02 = t1;

	return G*y2;
}

#undef A11
#undef A21
#undef B01
#undef B11
#undef B21

#undef A12
#undef A22
#undef B02
#undef B12
#undef B22

#undef G

/******************************************************************************/

#define A11 -1.53842908421193f
#define A21 0.84855856514738f
#define B01	0.14854092486721f
#define B11	-0.18034827240976f
#define B21 0.14854092486721f

#define A12	-1.71544355837494f
#define A22 0.88466680917388f
#define B02 7.79767408119502f
#define B12 -15.05579486140652f
#define B22 7.79767408119503f

#define G 0.08332454239234f

float filter2( float x ) 
{ 
	static float d01 = 0.0;
	static float d11 = 0.0;
	static float d02 = 0.0;
	static float d12 = 0.0;
	float y1, y2, t0, t1;

	/* first 2nd-order filter stage */
	t0 = x - A11*d01 - A21*d11;
	y1 = B01*t0 + B11*d01 + B21*d11;
	d11 = d01;
	d01 = t0;
	/* second 2nd-order filter stage */
	t1 = y1 - A12*d02 - A22*d12;
	y2 = B02*t1 + B12*d02 + B21*d12;
	d12 = d02;
	d02 = t1;

	return G*y2; 
}


#undef A11
#undef A21
#undef B01
#undef B11
#undef B21

#undef A12
#undef A22
#undef B02
#undef B12
#undef B22

#undef G

/******************************************************************************/

#define A11 -0.68409535605940f 
#define A21  0.81492279180742f
#define B01	 0.27236347795640f
#define B11	-0.00976249855546f   
#define B21  0.27236347795640f

#define A12	-1.03911439917059f 
#define A22  0.83366555983124f
#define B02  2.13458312080822f
#define B12 -3.28873727029416f
#define B22  2.13458312080822f

#define G    0.17130780020174f

float filter3( float x ) 
{ 
	static float d01 = 0.0;
	static float d11 = 0.0;
	static float d02 = 0.0;
	static float d12 = 0.0;
	float y1, y2, t0, t1;

	/* first 2nd-order filter stage */
	t0 = x - A11*d01 - A21*d11;
	y1 = B01*t0 + B11*d01 + B21*d11;
	d11 = d01;
	d01 = t0;
	/* second 2nd-order filter stage */
	t1 = y1 - A12*d02 - A22*d12;
	y2 = B02*t1 + B12*d02 + B21*d12;
	d12 = d02;
	d02 = t1;

	return G*y2; 
}

#undef A11
#undef A21
#undef B01
#undef B11
#undef B21

#undef A12
#undef A22
#undef B02
#undef B12
#undef B22

#undef G

/******************************************************************************/

#define A11   0.10267001417836f
#define A21   0.82136833847176f 
#define B01	  0.35674871341912f
#define B11	 -0.19766424653713f
#define B21   0.35674871341912f 

#define A12	  0.49110760091747f
#define A22   0.82712351283885f
#define B02   1.56380116360973f
#define B12   1.71597288553293f
#define B22   1.56380116360973f 

#define G     0.17852339322998f

float filter4( float x ) 
{ 
	static float d01 = 0.0;
	static float d11 = 0.0;
	static float d02 = 0.0;
	static float d12 = 0.0;
	float y1, y2, t0, t1;

	/* first 2nd-order filter stage */
	t0 = x - A11*d01 - A21*d11;
	y1 = B01*t0 + B11*d01 + B21*d11;
	d11 = d01;
	d01 = t0;
	/* second 2nd-order filter stage */
	t1 = y1 - A12*d02 - A22*d12;
	y2 = B02*t1 + B12*d02 + B21*d12;
	d12 = d02;
	d02 = t1;

	return G*y2; 
}

#undef A11
#undef A21
#undef B01
#undef B11
#undef B21

#undef A12
#undef A22
#undef B02
#undef B12
#undef B22

#undef G


/******************************************************************************/

#define A11  -0.21056140351043f
#define A21   0.09788861328985f
#define B01	  0.24406979722562f
#define B11	 -0.38256354918778f
#define B21   0.24406979722561f 

#define A12	  0.18598749427533f
#define A22   0.59703380841889f
#define B02   1.06503129234894f
#define B12  -0.36602825038992f
#define B22   1.06503129234894f

#define G     0.84950884997695f

float filter5( float x ) 
{ 
	static float d01 = 0.0;
	static float d11 = 0.0;
	static float d02 = 0.0;
	static float d12 = 0.0;
	float y1, y2, t0, t1;

	/* first 2nd-order filter stage */
	t0 = x - A11*d01 - A21*d11;
	y1 = B01*t0 + B11*d01 + B21*d11;
	d11 = d01;
	d01 = t0;
	/* second 2nd-order filter stage */
	t1 = y1 - A12*d02 - A22*d12;
	y2 = B02*t1 + B12*d02 + B21*d12;
	d12 = d02;
	d02 = t1;

	return G*y2; 
}

#undef A11
#undef A21
#undef B01
#undef B11
#undef B21

#undef A12
#undef A22
#undef B02
#undef B12
#undef B22

#undef G



// H Files (Header Files)

// Resource.h

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by SR.RC
//
#define IDD_ABOUTBOX				100
#define IDR_MAINFRAME				128
#define IDR_SRTYPE				129

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS			1
#define _APS_NEXT_RESOURCE_VALUE	130
#define _APS_NEXT_CONTROL_VALUE		1000
#define _APS_NEXT_SYMED_VALUE		101
#define _APS_NEXT_COMMAND_VALUE		32771
#endif
#endif

// Sr.h : main header file for the SR application
//

#if !defined(AFX_SR_H__EA5793C8_3742_44AB_973C_492A03D161DC__INCLUDED_)
#define AFX_SR_H__EA5793C8_3742_44AB_973C_492A03D161DC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CSrApp:
// See Sr.cpp for the implementation of this class
//

class CSrApp : public CWinApp
{
public:
	CSrApp();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSrApp)
	public:
	virtual BOOL InitInstance();
	//}}AFX_VIRTUAL

// Implementation
	//{{AFX_MSG(CSrApp)
	afx_msg void OnAppAbout();
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SR_H__EA5793C8_3742_44AB_973C_492A03D161DC__INCLUDED_)

// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINFRM_H__FC743F24_17FF_4976_A954_76F45F015658__INCLUDED_)
#define AFX_MAINFRM_H__FC743F24_17FF_4976_A954_76F45F015658__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMainFrame : public CFrameWnd
{
	
protected: // create from serialization only
	CMainFrame();
	DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMainFrame)
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMainFrame();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
	CStatusBar  m_wndStatusBar;
	CToolBar    m_wndToolBar;

// Generated message map functions
protected:
	//{{AFX_MSG(CMainFrame)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__FC743F24_17FF_4976_A954_76F45F015658__INCLUDED_)


// SrDoc.h : interface of the CSrDoc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_SRDOC_H__429DB63A_FDEA_43B7_876B_0D4740415BB8__INCLUDED_)
#define AFX_SRDOC_H__429DB63A_FDEA_43B7_876B_0D4740415BB8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CSrDoc : public CDocument
{
protected: // create from serialization only
	CSrDoc();
	DECLARE_DYNCREATE(CSrDoc)

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSrDoc)
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CSrDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CSrDoc)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SRDOC_H__429DB63A_FDEA_43B7_876B_0D4740415BB8__INCLUDED_)


// SrView.h : interface of the CSrView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_SRVIEW_H__E1E1804A_0AFB_4704_9E84_9509DF4307BA__INCLUDED_)
#define AFX_SRVIEW_H__E1E1804A_0AFB_4704_9E84_9509DF4307BA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CSrView : public CView
{
protected: // create from serialization only
	CSrView();
	DECLARE_DYNCREATE(CSrView)

// Attributes
public:
	CSrDoc* GetDocument();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSrView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CSrView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CSrView)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in SrView.cpp
inline CSrDoc* CSrView::GetDocument()
   { return (CSrDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SRVIEW_H__E1E1804A_0AFB_4704_9E84_9509DF4307BA__INCLUDED_)

// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__B75DB13B_0532_471C_9389_18361FBEE84A__INCLUDED_)
#define AFX_STDAFX_H__B75DB13B_0532_471C_9389_18361FBEE84A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls

#include "SendKeys.h"
#endif // _AFX_NO_AFXCMN_SUPPORT


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__B75DB13B_0532_471C_9389_18361FBEE84A__INCLUDED_)


// Traps.h
 
 #ifndef _M68KNOMMU_TRAPS_H
 #define _M68KNOMMU_TRAPS_H
 
 #ifndef __ASSEMBLY__
 
 typedef void (*e_vector)(void);
 
 extern e_vector vectors[];
 
 #endif
 
 #define VEC_BUSERR  (2)
 #define VEC_ADDRERR (3)
 #define VEC_ILLEGAL (4)
 #define VEC_ZERODIV (5)
 #define VEC_CHK     (6)
 #define VEC_TRAP    (7)
 #define VEC_PRIV    (8)
 #define VEC_TRACE   (9)
 #define VEC_LINE10  (10)
 #define VEC_LINE11  (11)
 #define VEC_RESV1   (12)
 #define VEC_COPROC  (13)
 #define VEC_FORMAT  (14)
 #define VEC_UNINT   (15)
 #define VEC_SPUR    (24)
 #define VEC_INT1    (25)
 #define VEC_INT2    (26)
 #define VEC_INT3    (27)
 #define VEC_INT4    (28)
 #define VEC_INT5    (29)
 #define VEC_INT6    (30)
 #define VEC_INT7    (31)
 #define VEC_SYS     (32)
 #define VEC_TRAP1   (33)
 #define VEC_TRAP2   (34)
 #define VEC_TRAP3   (35)
 #define VEC_TRAP4   (36)
 #define VEC_TRAP5   (37)
 #define VEC_TRAP6   (38)
 #define VEC_TRAP7   (39)
 #define VEC_TRAP8   (40)
 #define VEC_TRAP9   (41)
 #define VEC_TRAP10  (42)
 #define VEC_TRAP11  (43)
 #define VEC_TRAP12  (44)
 #define VEC_TRAP13  (45)
 #define VEC_TRAP14  (46)
 #define VEC_TRAP15  (47)
 #define VEC_FPBRUC  (48)
 #define VEC_FPIR    (49)
 #define VEC_FPDIVZ  (50)
 #define VEC_FPUNDER (51)
 #define VEC_FPOE    (52)
 #define VEC_FPOVER  (53)
 #define VEC_FPNAN   (54)
 #define VEC_FPUNSUP (55)
 #define VEC_UNIMPEA (60)
 #define VEC_UNIMPII (61)
 #define VEC_USER    (64)
 
 #define VECOFF(vec) ((vec)<<2)
 
 #ifndef __ASSEMBLY__
 
 /* Status register bits */
 #define PS_T  (0x8000)
 #define PS_S  (0x2000)
 #define PS_M  (0x1000)
 #define PS_C  (0x0001)
 
 /* structure for stack frames */
 
 struct frame {
     struct pt_regs ptregs;
     union {
             struct {
                     unsigned long  iaddr;    /* instruction address */
             } fmt2;
             struct {
                     unsigned long  effaddr;  /* effective address */
             } fmt3;
             struct {
                     unsigned long  effaddr;  /* effective address */
                     unsigned long  pc;       /* pc of faulted instr */
             } fmt4;
             struct {
                     unsigned long  effaddr;  /* effective address */
                     unsigned short ssw;      /* special status word */
                     unsigned short wb3s;     /* write back 3 status */
                     unsigned short wb2s;     /* write back 2 status */
                     unsigned short wb1s;     /* write back 1 status */
                     unsigned long  faddr;    /* fault address */
                     unsigned long  wb3a;     /* write back 3 address */
                     unsigned long  wb3d;     /* write back 3 data */
                     unsigned long  wb2a;     /* write back 2 address */
                     unsigned long  wb2d;     /* write back 2 data */
                     unsigned long  wb1a;     /* write back 1 address */
                     unsigned long  wb1dpd0;  /* write back 1 data/push data 0*/
                     unsigned long  pd1;      /* push data 1*/
                     unsigned long  pd2;      /* push data 2*/
                     unsigned long  pd3;      /* push data 3*/
             } fmt7;
             struct {
                     unsigned long  iaddr;    /* instruction address */
                     unsigned short int1[4];  /* internal registers */
             } fmt9;
             struct {
                     unsigned short int1;
                     unsigned short ssw;      /* special status word */
                     unsigned short isc;      /* instruction stage c */
                     unsigned short isb;      /* instruction stage b */
                     unsigned long  daddr;    /* data cycle fault address */
                     unsigned short int2[2];
                     unsigned long  dobuf;    /* data cycle output buffer */
                     unsigned short int3[2];
            } fmta;
             struct {
                     unsigned short int1;
                     unsigned short ssw;     /* special status word */
                     unsigned short isc;     /* instruction stage c */
                     unsigned short isb;     /* instruction stage b */
                     unsigned long  daddr;   /* data cycle fault address */
                     unsigned short int2[2];
                     unsigned long  dobuf;   /* data cycle output buffer */
                     unsigned short int3[4];
                     unsigned long  baddr;   /* stage B address */
                     unsigned short int4[2];
                     unsigned long  dibuf;   /* data cycle input buffer */
                     unsigned short int5[3];
                     unsigned       ver : 4; /* stack frame version # */
                     unsigned       int6:12;
                     unsigned short int7[18];
             } fmtb;
     } un;
 };
 
 #endif /* __ASSEMBLY__ */
 
 #endif /* _M68KNOMMU_TRAPS_H */
 
Laatst bewerkt door een moderator:
Ir vermoed dat het hier in zit:
Code:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

Wat probeer je uberhaubt te doen?
 
Antwoord voor Niek

Oke thanks maar om even in te gaan op je vraag Niek ik wil een spraakherkennings progje maken omdat ik het zat ben om constant afhankelijk te zijn van Sapi en al die andere software. Deze code blijkt goed te werken (niet door mij geschreven) is zeer accuraat maar in een andere c++ omgeving geschreven met een andere compiler.
 
Meer suggestie's en oplossingen zijn zeker welkom probleem is nog niet gefixt
 
Fout gevonden opgelost nu andere fout

Beste mensen,

Ik heb de fout in de code hier onder opgelost.
De fout die ik maakte was dat ik een workspace had gebruikt met precompiled header files.

Dit veranderd en toen kwam ik de volgende fout tegen:


// ERROR warning C4244: '=' : conversion from 'double' to 'float', possible loss of data





void analyze( float *sample, float *fingerprint )
{
int i, k, x;
k = 0;
for( i=0; i < NSAMPLES; i+= NSAMPLES_PER_INTERVAL ) {
int j;
double y1=0.0f, y2=0.0f, y3=0.0f, y4=0.0f, y5=0.0f;
double m;

for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
float y = filter1( sample[i+j] );
y1 += y*y;
}
m = frexp(y1+1, &x);
fingerprint[k++] = x+m; // error

for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
float y = filter2( sample[i+j] );
y2 += y*y;
}
m = frexp(y2+1, &x); // error
fingerprint[k++] = x+m;

for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
float y = filter3( sample[i+j] );
y3 += y*y;
}
m = frexp(y3+1, &x); // error
fingerprint[k++] = x+m;

for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
float y = filter4( sample[i+j] );
y4 += y*y;
}
m = frexp(y4+1, &x); // error
fingerprint[k++] = x+m;

for( j=0; j < NSAMPLES_PER_INTERVAL; j++ ) {
float y = filter5( sample[i+j] );
y5 += y*y;
}
m = frexp(y5+1, &x); // error
fingerprint[k++] = x+m;
}
}



Boven in vind je de soort fout het betreft hier een conversie fout
De variable die hier bij betrokken zijn, zijn de x en de m.
Waar de fouten zich begeven wordt aangegeven door // error.
Ik hoop dat iemand mij hier mee kan helpen.
 
Een float is kleiner dan een double (namelijk de helft) waardoor je bij toekenning van een double aan een float mogelijks data verliest als deze niet in het bereik van een float ligt.

Indien je die analyse-functie zelf schrijft zou ik aanraden om de argumenten van het type double te maken, net wegens de extra precisie.
Indien je die precisie niet nodig hebt, kan je op de toekenningsregels (die met de error) zelf een cast uitvoeren. Ik denk dat deze methode het eenvoudigste is: Je zet het huidige rechterlid tussen haakjes en je zet er het doeltype tussen haakjes voor. Bvb:
Code:
fingerprint[k++] = (float)(x+m);

ohja.. als je hier code post, gelieve gebruik te maken van [ CODE ] en [ /CODE ] (maar dan zonder spaties) en intendatie
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan