VB icon

Guitar Note Recognizer

Email
Submitted on: 1/5/2015 4:17:00 PM
By: Mecoli (from psc cd)  
Level: Advanced
User Rating: By 2 Users
Compatibility: C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Views: 608
 
     A study about the structure of audio format and digital musical notes is also required in order to accomplish the project. The aim of this project is to produce a program that will analyze a music track and output the guitar notes that were played on the track. This Microsoft Windows platform software application will be able to listen for acoustic guitar sounds from tracks where only one guitar is being played. The data will be outputted in tab notation. By creating this software, the public especially guitar players can get the guitar notes directly from the audio file (WAV format), probably from a Compact Disc without wasting money to buy music book from the shop or search the scores from the internet. Please visit website:: http://softworld.filetap.com

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Guitar Note Recognizer
// Description:A study about the structure of audio format and digital musical notes is also required in order to accomplish the project. The aim of this project is to produce a program that will analyze a music track and output the guitar notes that were played on the track. This Microsoft Windows platform software application will be able to listen for acoustic guitar sounds from tracks where only one guitar is being played. The data will be outputted in tab notation. By creating this software, the public especially guitar players can get the guitar notes directly from the audio file (WAV format), probably from a Compact Disc without wasting money to buy music book from the shop or search the scores from the internet.
Please visit website::
http://softworld.filetap.com
// By: Mecoli (from psc cd)
//**************************************

//Below is my one of the guitar note generator 
//program, to get the source code pls go my 
//website
//http://softworld.filetap.com
//
#include "stdafx.h"
#include "aunew.h"
#include "mainfrm.h"
#include "NoteGenerator.h"
#include "winex.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
NoteGenerator::NoteGenerator(CNoteFre *spec, CAuNewView *tmp, int samplesPerBuf,int samplesPerSec,
							 int fftPoints) 
							 : 
	
	_specView(spec),	
	_wavView(tmp),
	_samplesPerBuf (samplesPerBuf),
_samplesPerSecond (samplesPerSec),
_fftPoints (fftPoints),
	_bitsPerSample(16),
_pFftTransformer (fftPoints, samplesPerSec),
_pListener (samplesPerBuf, samplesPerSec),
	_isActive(0),
	_listenMode(0)
{
}
NoteGenerator::~NoteGenerator()
{
}
//Starts a thread and waits for command to resume
void NoteGenerator::Run()
{
	//Infinite loop waiting 
for (;;)
{
_event.Wait ();
if (_isDying)
return;
		//Lock makes sure control remains with current thread
Lock lock (_mutex);
		_isActive = 1;
if (_pListener->IsBufferDone ())
			//Main control funciton
			LokWaveInData ();
}
}
//Re-initializes the Listener
BOOL NoteGenerator::ReInit(int samplesPerBuf, 
int samplesPerSec, 
int fftPoints,
int bitsPerSample)
{
Lock lock (_mutex);
if (_pListener->BitsPerSample() == bitsPerSample &&
_pListener->SamplesPerSecond() == samplesPerSec &&
_pFftTransformer->Points() == fftPoints &&
_pListener->SampleCount() == samplesPerBuf)
{
return TRUE;
}
_samplesPerBuf = samplesPerBuf;
_samplesPerSecond = samplesPerSec;
_fftPoints = fftPoints;
_bitsPerSample = bitsPerSample;
BOOL isStarted = _pListener->IsStarted();
if (isStarted)
_pListener->Stop();
BOOL isError = FALSE;
try
{
_pFftTransformer.ReInit ( _fftPoints, _samplesPerSecond);
_pListener.ReInit (_bitsPerSample, _samplesPerBuf, _samplesPerSecond);
}
catch ( WinException e )
{
char buf[50];
wsprintf ( buf, "%s, Error %d", e.GetMessage(), e.GetError() );
MessageBox (0, buf, "Exception", MB_ICONEXCLAMATION | MB_OK);
isError = TRUE;
}
catch (...)
{
MessageBox (0, "Unknown", "Exception", MB_ICONEXCLAMATION | MB_OK);
isError = TRUE;
}
if (isStarted)
{
isError = !_pListener->Start(_event);
}
return !isError;
}
void NoteGenerator::LokWaveInData()
{
	//An iterator class used to access the Listener data
	SampleIter iter (_pListener.GetAccess());
// Quickly release the buffer
if (!_pListener->BufferDone ())
return;
//Copy the data into the FFT buffer and perform transform on it
	_pFftTransformer->CopyIn (iter);
_pFftTransformer->Transform();
	
	//Update the spectrograph
	char ret[3];
	
	_specView->Update (_pFftTransformer.GetAccess(), ret);
}
BOOL NoteGenerator::Start ()
{
	Lock lock (_mutex);
_isActive = 1;
	//Start the Listener recording from the soundcard
	return _pListener->Start (_event);
}
void NoteGenerator::Stop ()
{
	Lock lock (_mutex);
_isActive = 0;
	//Stop it recording
	_pListener->Stop ();
}
//That is my one of the guitar note generator 
//program, to get the complete source code, or for more information pls go my website
//http://softworld.filetap.com


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.