블로그 전문 “이글루스”에 오신 것을 환영합니다.

블로그 전문 “이글루스”에 오신 것을 환영합니다.
새로운 보금자리, 이것저것 어색한 것이 많으시죠?
포털블로그와는 다른, 이글루스만의 기능, 이글루스의 특징을 소개해드립니다.

이글루스는 블로그전문을 지향합니다.
2004년, 첫 발을 내디딘 이글루스는 국내 최초 트랙백 을 도입하여 블로그전문 서비스로 입지를 다졌습니다. 관심사를 공유할 수 있는 ‘ 밸리’와 ‘마이’, 문화체험의 새로운 경험 ‘렛츠리뷰’, 국내 최고 메신저 네이트온 연동으로 더욱 새로운 블로깅, 독보적인 블로거가 되세요!

첫째, 공감하는 글이 있다면, 트랙백핑백을 이용하세요!
기존 포털 블로그에서 사용하던 스크랩기능 대신 트랙백과 핑백을 사용해보세요~
관심사가 비슷한 블로거를 만날 수 있는 방법입니다!

둘째, 일촌, 친구, 이웃 등 오프라인 인맥 위주의 ‘친구맺기’ 기능이 필요하시면!
이글루스에서 제공하는 이글루링크를 추천해드립니다.
이글루링크를 하시면, 해당 블로거의 새글 업데이트 소식을 실시간으로 받아볼 수 있습니다.

셋째, 카테고리별 공개/비공개 설정을 지원하지 않습니다.
이글루스는 자신이 작성한 글을 더 많은 블로거들과 나눌 수 있도록 참여와 공유를 지향합니다.
카테고리별 공개/비공개 기능은 현재 마련되어 있지 않으나 추후 필요성을 검토해보도록 하겠습니다.

넷째, 도움이 필요할 땐, EBC 와 이글루스도움말 을 찾아주세요.
이글루스를 이용하시다 발견되는 버그나 오류, 그리고 요청사항은 운영자 공식블로그 EBC 를, 이글루스의 기능과 운영정책을 알고 싶으시다면 이글루스 도움말을 방문하세요!

※ 공지사항을 지우고 싶은 경우, 포스트의 ‘삭제’를 클릭하면 지워집니다.
※ 삭제 버튼은 한 번만 누르세요. 여러 번 클릭 시 다른 글이 삭제될 수도 있습니다.

by 바다777 | 2009/04/22 06:20

오디오 오실로스코프 아날라이져

Sample Image

Introduction

This is a simple application I built to understand the basics of the Windows Audio WAVE API, and to get a basic grasp on Fast Fourier Transforms (FFTs). Features of the application are: double buffering graphics, sampling an audio source, selecting an audio recording source using the mixer, calculating the FFT spectrum array, and plotting sampled data.

Background

I won't discus the details of FFT here as the math is a little beyond me. Basically, it involves complex numbers (those number like sqrt(-1)) and calculating discrete Sin/Cos transformations on sampled date. Google for many and better explanations on FFT.

Using the code

If you look through the example, you will find it quite a simple affair that has not been touched by MFC. This means that the code is easy to follow and easy to transplant into your projects. The basic flow of the program is:
  • Load a dialog window and initialize it.
  • Select the recording device (which is harder than it should be!).
  • Initialize the WAVE structures.
  • Activate the sampling.
  • Determine the status of the sampling.
  • Process the sampled data using FFT.
  • Clean up.
In the FFT process, I load the sampled data into an iterator class for processing within the FFT class. This allow for selective processing of the sampled data. In this case, I sampled the recording source in stereo, and I can selectively process the left or the right channels within the FFT class, or both channels at once. Both classes are simple to follow and to implement.

Points of interest

The audio device API within Windows is far more complex than it should be. This is pretty common when dealing with Microsoft, they never seem to make things easy! A classic example is dealing with the Audio Mixer. It took some time to find some code that can do the most basic of tasks (select a recording device), and even that is not 100% perfect. Device drivers may incorrectly label a recording device as a WAVEOUT device and the program will return an error when trying to record from it, so look out for such errors (use the VC6 debugger to determine the fault in such occurrences).
In fact, I would not recommend using the WAVE API for anything too complex as it tends to be a bit tricky to use, instead look at the Simple Directmedia Layer library, and specifically the mixer lib, which is a good example of making things simple and useful to the programmer.
The FFT implementation probably isn't the fastest around. I originally converted the source from a Java class, and then optimized the Cos/Sin processing to implement a look up table to speed things up significantly, and added a few helper methods; otherwise it has remained unchanged.

History

  • Updated the spectrum graphics to be more equalised.
  • Fixed a number of small bugs.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Steven De Toni



Location: New Zealand New Zealand

Other popular Audio and Video articles:


[출처] 오디오 오실로스코프 아날라이져


oscilloscope_src.zip

by 바다777 | 2008/04/05 22:32 |  ▶VC++ | 트랙백 | 덧글(0)

스팩트럼 콘트롤

Introduction

This is another simple Spectrum/Bar Histogram control which can be easily incorporated in your multimedia project or something similar. They usually display an array of FFT generated value from decoded PCM sequence value of compressed audio data.

How to use it

There are only few steps to use this control:
  • Include two files, SpectrumCtrl.h and SpectrumCtrl.cpp in your project
  • Create a Picture box (Frame) in your form/dialog
  • Change it's ID to whatever you want
  • Include SpectrumCtrl.h in the class declaration of your form/dialog
  • Put this in your dialog/form class:
    CSpectrumCtrl   m_spectrumboard;
    
  • Create an instance of CSpectrumCtrl class in your application
    CWnd *m_pWnd;
    
  • Initialize the control, usually within OnInitDialog() in dialog or OnInitialUpdate() in form:
    m_pWnd = (CWnd*) GetDlgItem(IDC_STATIC_PICTURE_BOX_ID); m_spectrumboard.Create(JUMLAH_ELEMENT_ARRAY, 20, &CSize(4, 1),     WS_VISIBLE | WS_CHILD | WS_TABSTOP, m_pWnd, this, 1000);
    
    CSize(4, 1) means the size of the block/cell element in the spectrum board is 4 pixel width and 1 pixel height
  • Call the following method to visualize an integer array:
    m_spectrum.DisplayArray(iPtrNilai);
    
You can modify the following constants in the source code for visual appearance customization:
#define SPASI_ANTAR_CELL     1 #define PEAK_DROP_SPEED      1 #define PEAK_HEIGHT          1 #define MAX_PEAK_LIVE_TIME   7 #define PEAK_TOLERANT        2 // 2 blocks

Description of each constant

  • SPASI_ANTAR_CELL is the blank space between cells/blocks in the spectrum board
  • PEAK_DROP_SPEED is the gravitation value for the peaks
  • PEAK_HEIGHT is height of the peaks in pixel
  • MAX_PEAK_LIVE_TIME is the number to suspend peaks before get affected by gravitation
  • PEAK_TOLERANT is the restricted blocks/cells area at top of the spectrum board

Conclusion

This class will have it's own window size by modifying your picture box place holder at run-time. Cheers!

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

About the Author

Danang Suharno Ngadinegaran



Occupation: Web Developer
Location: Indonesia Indonesia

Other popular Miscellaneous articles:


[출처] 스팩트럼 콘트롤

by 바다777 | 2008/04/05 22:31 |  ▶VC++ | 트랙백 | 덧글(0)

CreateFont 멤버 변수 설명

BOOL CreateFont(
int nHeight, // 폰트의 높이
int nWidth, //폰트의 가로크기
int nEscapement, // escapement 벡터각도
int nOrientation, // 기준선(보통 수평선) 에서의 각도
int fnWeight, // 폰트 가중치
DWORD fdwItalic, // 이탤릭 속성 플러그
DWORD fdwUnderline, // 밑줄 속성 플러그
DWORD fdwStrikeOut, // 중앙선 속성 플러그
DWORD fdwCharSet, // 문자열 세트 명칭
DWORD fdwOutputPrecision, // 출력 정밀도
DWORD fdwClipprecision, // 클리핑 정밀도
DWORD fdwQuality, // 출력 문자의 질
DWORD fdwPitchAndFamily, // 글꼴 피치의 종류
LPCSTR lpszFace // 폰트체의 이름

[출처] CreateFont 멤버 변수 설명

by 바다777 | 2008/04/05 22:30 |  ▶VC++ | 트랙백 | 덧글(0)

CFile 클래스

[강좌] CFile 클래스.... 윈도우즈에서 파일 입출력에 대한 처리방법은 여러가지가 있는데, 가장 쉬
운방법은 MFC 클래스 라이브러리에서 기본적으로 제공되고 있는 표준 다이
얼로그 박스(Common Dialog Box)클래스를 이용하는 것입니다. 표준 다이얼
로그 박스는 문자열의 검색과 치환, 색상의 선택, 폰트의 선택, 프린팅에
대한 기능들도 표준 다이얼로그 박스 클래스로 제공되고 있기 때문에 이러
한 기능들을 프로그램에 지원하고자 할 때는 표준 다이얼로그 박스를 이용
하는 것이 훨씬 용이합니다.
Visual C++은 윈도우즈 상에서 보다 효율적으로 파일처리를 할 수 있도록
CFile 클래스와 직렬화(Serialization)기능을 제공하고 있습니다.
CFile 클래스
MFC는 표준 파일 처리를 위해 CFile 클래스를 제공하고 있습니다. 이 CFile
클래스에는 파일처리를 위한 많은 멤버함수들이 포함되어 있는데, 이러한
함수들은 이전에 도스상에서 자주 다루어 보았던 함수들과 유사합니다.
멤버함수 의미
CFile()
Abort()
Duplicate()
Open()
Close() 
 
Read()
Write()
Flush() 
 
Seek()
SeekToBegin()
SeekToEnd()
GetLength()
SetLength()
 
LockRange()
UnlockRange()
 
GetPosition()
GetStatus()
GetFileName()
GetFileTitle()
GetFilePath()
SetFilePath()
 
Rename()
Remove()
GetStatus()
SetStatus() 
객체 생성자.
모든 경고와 에러들을 무시하고 화일을 닫는다.
오브젝트 복사.
파일을 연다.
파일 종료 및 오브젝트 삭제.
 
파일로 부터 데이타를 읽는다.
현재파일 위치에 데이타를 쓴다.
데이타를 제거한다.   
  
파일포인터를 이동한다.
파일 포인터를 처음으로 이동한다.
파일 포인터를 끝으로 이동한다.
파일의 길이를 얻는다.
파일의 길이를 지정한다.
   
파일의 일부를 락(Lock)을 건다.
파일의 일부를 락에서 해제한다. 
 
파일의 포인터를 얻는다.
지정된 파일의 상태를 얻는다.
선택된 파일의 파일이름을 얻는다.
선택된 파일의 타이틀을 얻는다.
선택된 파일의 전체 경로를 얻는다.
선택된 파일의 전체 경로를 설정한다.  
 
지정된 파일을 다른이름으로 변경한다.
지정된 파일을 제거한다.
지정된 파일의 상태를 얻는다.
지정된 파일의 상태를 설정한다.      
멤버함수들을 알았으니 CFile 클래스로 파일 쓰기와 파일 읽기 예제를 보
면서 공부해 보겠습니다.
#파일쓰기 예제
void CFileioView::OnWritefile()
{
CFile Wfile;
if(!Wfile.Open("TestFile.txt", CFile::modeCreate :
CFile::modeWrite))
{
MessageBox("Can't Create testfile.txt !", "Warning",
MB_OK : MB_ICONHAND);
return;
}
char* ps = new char[27];
char* ps2 = ps;
for(int i=0;i<26;i++)
*ps2++ = 'A'+i;
*ps2 = NULL; // NULL 문자로 끝나게 한다.
Wfile.Write(ps,27);
Wfile.Close();
delete ps;
}
#파일읽기 예제
void CFileioView::OnReadfile()
{
CFile Rfile;
if(!Wfile.Open("TestFile.txt", CFile::modeRead))
{
MessageBox("Can't Open testfile.txt !", "Warning",
MB_OK : MB_ICONHAND);
return;
}
UINT FileLength = (UINT)Rfile.GetLength();
char* ps = new char[FileLength];
Rfile.Read(ps,FileLength);
Rfile.Close();
CClientDC dc(this);
dc.TextOut(0,0,ps,lstrlen(ps));
delete ps;
}
마지막으로 파일의 특정위치에 데이타를 읽거나 쓸수 있도록 처리해주는
CFile 클래스의 Seek()멤버함수를 이용해보겠습니다.
#랜덤 파일 처리 예제
void CFileioView::OnAddfile()
{
CFile Afile;
if(!Afile.Open("TestFile.txt", CFile::modeRead :
CFile::modeWrite))
{
MessageBox("Can't Create testfile.txt !", "Warning",
MB_OK : MB_ICONHAND);
return;
}
Afile.Seek(-1,CFile::end);
~~~~~~~~~~~~~
char* ps = new char[27];
char* ps2 = ps;
for(int i=0;i<26;i++)
*ps2++ = 'a'+i;
*ps2 = NULL; // NULL 문자로 끝나게 한다.
Wfile.Write(ps,27);
Wfile.Close();
delete ps;
}
참고로 Seek()함수에 대해서 알아보겠습니다...
Seek()함수의 첫번째 매개 변수는 양수이면 앞쪽으로 파일포인터를 이동하
고, 음수이면 뒷쪽으로 파일포인터를 이동합니다. 두번째 매개 변수는 파일
의 첫번째 위치를 기준으로 파일포인터를 이동하고자 하면 CFile:begin 플
래그를 사용하고, 현재위치나 파일의 마지막을 기준으로 이동하고자 한다면
CFile::end 플래그를 사용하면 됩니다.
CFile 클래스는 이 함수 외에도 SeekToBegin()와 SeekToEnd()함수를 제공
하고 있습니다.
이번엔 파일의 예외처리에 대해서 알아보겠습니다...
⊙ 예외처리(Exception Handling)
MFC는 파일예외처리를 위해서 CFileException 클래스를 제공하고 있습니다
CFileException 클래스는 파일을 오픈하면서 발생되는 여러가지 에러에 관
련된 정보를 포함하고 있습니다.
파일처리에 있어서 발생되는 에러는 CFileException 클래스의 m_cause 데
이타 멤버의 값을 참조하게 됩니다. 파일 에러가 발생했을때 m_cause데이타
멤버에 발생된 에러코드가 들어가게 되는데, 이것들에는 다음과 같은 것들
이 있습니다.
에러코드
none
generic
fileNotFound
badPath
tooManyOpenFiles
accessDenied
invalidFile
removeCurrentDir
directoryFull
badSeek
hardIO
sharingViolation
lockViolation
diskFull
endOfFile
에러가 없다
일반적인 에러
파일이 존재하지 않는다
파일 경로가 맞지 않다
허용된 파일 오픈 수를 넘었다
파일 접근 금지
파일에 이상이 있다
현재 디렉토리를 제거할 수 없다
디렉토리가 모두 찼다
파일 포인터 지정에러
하드웨어 에러
SHARE.EXE가 로드되지 않았거나 공유된 지역에 락이 걸렸을 경우
이미 락이 걸려 있는 지역에 락을 시도했다
디스크가 모두 찼다
파일의 끝에 도달하였다
실행에러 즉, 예외처리를 하는 TRY, CATCH, END_CATCH 매크로가 사용됩니
다. 이들 매크로는 메모리(CMemoryException), 리소스(CResourceException)
, OLE(COleException)등에 관련된 예외처리를 담당합니다.
예>
// example for CFileException::m_cause
extern char* pFileName;
TRY
{
CFile f(pFileName, CFile::modeCreate : CFile::modeWrite);
}
CATCH(CFileException, e)
{
if(e->m_cause == CFileException::fileNotFound)
??????
printf("ERROR : File not found\n");
}
이번엔 switch ~ case 문으로 해볼까요?
extern char* pFileName;
TRY
{
CFile f(pFileName, CFile::modeCreate : CFile::modeWrite);
}
CATCH(CFileException, e)
{
switch(e->m_cause)
{
case CFileException::fileNotFound :
??????
MessageBox("File not found");
break;
case CFileException::diskFull :
????
MessageBox("Disk is full");
break;


}
}
END_CATCH
[출처] CFile클래스|작성자 휴즈벌

[출처] CFile 클래스

by 바다777 | 2008/04/05 22:29 |  ▶VC++ | 트랙백 | 덧글(0)

<< 이전 페이지다음 페이지 >>