Click here to Skip to main content
15,893,644 members
Articles / Programming Languages / C#

A simple C# Wave editor, part 1: Background and analysis

Rate me:
Please Sign up or sign in to vote.
4.77/5 (80 votes)
5 Aug 200411 min read 356.1K   8.2K   132  
The first phase of a RIFF/Wave editing "swiss army knife", in which we'll learn how to extract all the data present in common Wave files and store it in an XML document.
// CPeak.h: interface for the CPeak class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CPEAK_H__EA90B675_44B8_11D3_9A58_0080C605ADA4__INCLUDED_)
#define AFX_CPEAK_H__EA90B675_44B8_11D3_9A58_0080C605ADA4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define TOTALBUFFER 128000

class CPeak  
{
public:
	CPeak();
	virtual ~CPeak();


	// Variables
	WORD*	m_lpPeaks;

	// pointer to our data
	WORD*	m_lpLPeak;
	WORD*	m_lpRPeak;
	
	long	m_lLTotal;
	long	m_lRTotal;
	long	m_lTotalSamples;


	// other stuff
	BOOL	m_bPeaksInitialized;
	WORD	m_lLCurrentPeak;
	WORD	m_lRCurrentPeak;
	long	m_lSampleInterval;
	long	m_lCounter;
	long	m_lTotalPeaks;
	CFile	m_fFile;
	BOOL	m_bFileOpen;
	// Funcs
	void	CheckAgainstCurrentPeaks			(WORD* lpLSample,WORD* lpRSample);
	void	SetPeaks							(WORD* lpLPeak,WORD* lpRPeak);
	void	ZeroOut								();
	void	IncreaseCounterAndUpdate			();
	void	Initialize							(long lInterval,CString sFilename);
	void	WriteOutBuffer						();
	void	EmptyOutBuffer						();
	void	Process								(WORD* lpLSample,WORD* lpRSample);
};

#endif // !defined(AFX_CPEAK_H__EA90B675_44B8_11D3_9A58_0080C605ADA4__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Canada Canada
Jonathan Kade is a native of Detroit, MI. He's interested in multimedia, hardware/software interfacing, working with low-level data, and low-level programming in general.

Comments and Discussions