<div dir="ltr">Dear Gary,<br><br> I am using my colleauge code written for real time voice command recording for a project but I could not compile this. I try to debug this but the message was:<br><br><br>/Users/asr/P21/recMain.h:39: error: 'RtAudioStreamStatus' has not been declared<br>
/Users/P21/recMain.h:61: error: 'StreamParameters' in class 'RtAudio' does not name a type<br>/Users/P21/recMain.h:84: error: 'DeviceInfo' in class 'RtAudio' does not name a type<br>/Users/P21/RtAudioInterface.cpp:17: error: 'RtAudioStreamStatus' has not been declared<br>
Process terminated with status 1 (0 minutes, 1 seconds)<br><br>I attached the program if you could please provide your advice and kind help what has been wrong here for using this RtAudio for recording some audio command.<br>
<br>#include "recMain.h"<br>#include "SILTT.h"<br>#include "names_P21.h"<br>using namespace P21;<br>#include <iostream><br>#include "FEATEXTR.h"<br><br>/*********************************************************************<br>
*********************************************************************<br> global C-style callbackfunction<br>*********************************************************************<br>**********************************************************************/<br>
int RtAudioInterface( void *outputBuffer,<br> void *inputBuffer,<br> unsigned int nBufferFrames,<br> double streamTime,<br> RtAudioStreamStatus status,<br>
void *callbackdata )<br>{<br> recFrame* gui= static_cast<recFrame*>(callbackdata);<br><br><br>#if wxUSE_STATUSBAR<br>{<br> if ( status ){<br> // (gui->statusBar)->SetStatusText(<br>
wxMessageBox(_("Streamoverflow detected"));//,0);<br> }<br><br> wxString t; t<<_("Time: ")<<streamTime<<_("\t|#: ")<<(gui->_calls);<br> (gui->statusBar)->SetStatusText(t,0);<br>
}<br>#endif<br><br> // sonst speichere "alles" im zwischenspeicher<br><br><br><br>// :::::::::::::::::::_calls<32 && _fb_counter<_fixed_analyze_size:::::::::::::::::::::::::::::::::::<br>real* buffer=static_cast<real*>(inputBuffer);<br>
<br>if(nBufferFrames!=1024){ wxString t; t<<nBufferFrames; wxMessageBox(t);}<br><br>for(unsigned k=0;k<1024;k+=4,++(gui->_fb_counter))<br> gui->_fixed_buffer[gui->_fb_counter]=(buffer[k]+<br> buffer[k+1]*2.0+<br>
buffer[k+2]*2.0+<br> buffer[k+3] )/6.0;<br><br>++(gui->_calls);<br>if( (gui->_calls<32) ) return 0;//speichere zwischen für calls=1,2,...,32<br>
<br><br><br><br><br>// hier _calls==32 (und größer)<br>// d.h. 32*(1024/4)=8192 reele daten gesammelt bis jetzt<br>// setzte gui->calls wieder auf null:<br> (gui->_calls)=0;<br> (gui->_fb_counter)=0;<br>// hier sollte die analyse dann starten<br>
/////////////////////////////////////////////////////////////////////////////////////////////////<br> /////////////////////////////////////////////////////////////////////////////////////////////////<br> /////////////////////////////////////////////////////////////////////////////////////////////////<br>
/////////////////////////////////////////////////////////////////////////////////////////////////<br> /////////////////////////////////////////////////////////////////////////////////////////////////<br> /////////////////////////////////////////////////////////////////////////////////////////////////<br>
/////////////////////////////////////////////////////////////////////////////////////////////////<br> /////////////////////////////////////////////////////////////////////////////////////////////////<br><br>/* mache folgende überlegung<br>
---- für US-1641 ------- :<br> Samplingfrequenz: 44100 Hz (entspricht in etwa 4/3* 2^15 Hz)<br> höchste Pufferlänge (bei einem Mikro) 2^10 Samples<br><br> wir nehmen NUR jeden 4-ten Punkt aus dem Puffer (-> Samplingfrequenz geht runter auf<br>
4/3* 2^13 Hz)<br> und schreiben ergebnis in ein zwischenspeicher: _fixed_buffer[0,...,2^13-1]<br> --- damit der ganze zwischenspeicher (nicht mehr und nicht weniger) ausgenutzt wird,<br> benutzen wir die variable (gui->calls), die in diesem fall nicht größer als 2^5 sein darf:<br>
nBufferFrames=2^10 ----> 2^8 werden abgespeichert in _fixed_buffer, das alles 2^5 mal, also<br> insgesamt 2^(8+5)<br>*/<br><br><br> //wxString t; t<<_("calls ")<<(gui->_calls)<<_("\n fb_counter: ")<<(gui->_fb_counter); gui->statusBar->SetStatusText(t,1);<br>
<br>//wxMessageBox(_("do analyze...\n"));<br>//(gui->_deviceinfo).name<br>// .sampleRates.size() --> .sampleRates[0,...]<br>//<br><br><br><br><br><br><br> Signal* _x=(gui->_x);<br> // this is already done in the recFrame-constructor:<br>
//"_x->RtAudioInterface( gui->_fixed_buffer, gui->_fixed_analyze_size );"<br> //=> gui->_fixed_analyze_size == _x->size()<br><br> SILTT analysis(static_cast<Signal&>(*_x), gui->_cost, gui->_costpar, 0.0);<br>
analysis.dct(*_x);<br><br><br> FEATEXTR& F = *(gui->_F);<br> F.compute(analysis);<br> F.frequency().draw(analysis);<br><br><br> wxString shift,bbsize, costval,par;<br> shift<<analysis.shift(); bbsize<<analysis.bbsize(); costval<<analysis.cost();<br>
gui->m_staticTextShiftIndex->SetLabel(shift); gui->m_staticTextBBSize->SetLabel(bbsize); gui->m_staticTextCostValue->SetLabel(costval);<br><br> par<<_("cost=")<<(gui->_costpar)<<_(" Freq:")<<(gui->_sampleRate)<<_(" buff= ")<<(gui->_bufferFrames)<<_(" F=")<<(gui->_cost)<br>
;//<<_(" µ=")<<meanfreq;<br> (gui->statusBar)->SetStatusText(par,1);<br><br><br><br>return 0;<br>/*******************************************************************************<br>********************************************************************************<br>
********************************************************************************<br>*******************************************************************************/<br>//compute a 2D (freq vs time) representation from analysis.dct-coeffs<br>
<br>// _bufferFrames==x.size() , x is a Signal-object<br><br>//analysis.show_dct();<br>// set switch to _dct -- used in SILTT::operator[](index i)<br>real* dct= analysis.get_add_dct();//*(analysis[0]);<br>//analysis.show_bbnodes();<br>
P21::index* node=analysis.get_add_bbnodes();//*(analysis[0]);<br><br><br>unsigned char g; // gray-code index: 0-255<br>//compute max(dct)///////////////////////<br>real maxdct=fabs(dct[0]); /////<br> for(P21::index i=1;i<_x->size();++i) /////<br>
if(maxdct<fabs( dct[i])) /////<br> maxdct=fabs( dct[i]); /////<br>/////////////////////////////////////////<br><br><br>P21::index dt, df;<br>wxString tmp;<br><br>// clear plot-area:<br>gui->_DCcoeffs.SetBrush(wxColour(0,0,0));(gui->_DCcoeffs).DrawRectangle( 0,0,<br>
2*gui->_scale_x,2*gui->_scale_y);<br><br>P21::index nxbox, nybox, b;<br>depth d;<br><br>if(analysis.bbsize()==1)<br>{//plot a graph<br> for(P21::index x=0;x<_x->size();++x)<br> gui->_DCcoeffs.DrawPoint(static_cast<wxCoord>(600+10*dct[x]),static_cast<wxCoord>(600 - 20-x/10));<br>
<br><br> dt=gui->_scale_x;<br> df=1;//gui->_scale_y;<br><br> for(P21::index i=0, y=gui->_scale_y;i<512||y>0;--y) // for each frequency-entry in a packet<br> {<br> g=static_cast<unsigned char>(ceil( 255*dct[++i]/maxdct ));<br>
<br> gui->_DCcoeffs.SetBrush(recFrame::GRAYMAP[ g ] );<br> gui->_DCcoeffs.SetPen(recFrame::GRAYMAP[ g ] );<br> gui->_DCcoeffs.DrawRectangle( 10,560-i,gui->_scale_x,1);<br><br> }<br>
return 0; // be carefull!!! every resetting of any variable, like _calls, should have been done before this step<br>}<br><br>for(P21::index t=10, i=0, p=0;p<analysis.bbsize();++p,t+=dt)// for each best-basis packet<br>
{//plot a plane<br><br><br><br> // d=floor(log2(node))<br> d=P21::_log2(node[p]); if(static_cast<P21::index>(1<<d)!= node[p]) --d;<br><br> nxbox=(1<<d); // <=> 2^d<br> // number of boxes in frequency(y)-direction <=> same as packetlength of node(p)<br>
nybox=( (gui->_fixed_analyze_size)>>d);// <=> N/2^d<br> //b=node[p]-nxbox;<br><br><br> //dt=static_cast<index>(( static_cast<double>(nxbox/(gui->_bufferFrames))*(gui->_scale_x) ));<br>
dt=static_cast<P21::index>( (gui->_scale_x)/nxbox );<br> // if(dt==0) continue;<br><br> //df=static_cast<index>(( static_cast<double>(nybox/(gui->_bufferFrames))*(gui->_scale_y) ));<br>
df=static_cast<P21::index>( (gui->_scale_y)/nybox );<br> // if(df==0) continue;<br><br><br> if(dt==0)// || df==0) // both should be non-zero<br> {<br> wxString s;<br> s<<_("nxBox=");<br>
s<<nxbox<<_(" nyBox=");<br> s<<nybox<<_("\n [node,d,b]=");<br> s<<node[p]<<_(", ");<br> s<<d<<_(", ");<br> s<<b;<br>
wxMessageBox(s);<br> continue;<br> }<br><br>P21::index K=1;<br>if( nybox>(gui->_scale_y) )<br>{<br> df=1;<br> K=nybox/(gui->_scale_y);<br> //wxString par; par<<_("K=")<<K;<br> // (gui->statusBar)->SetStatusText(par,1);<br>
continue;<br>}<br>//plote zeitliche partitionierung:<br>gui->_DCcoeffs.SetBrush(*wxRED_BRUSH);<br>gui->_DCcoeffs.DrawRectangle( t,0,dt,10);<br><br><br> //for(index f=10+(gui->_scale_y),y=0;y<nybox+1;++y,f-=df) // for each frequency-entry in a packet<br>
for(P21::index y=0,f=gui->_scale_y-df+100;y<nybox;++y,f-=df) // for each frequency-entry in a packet<br> {<br> if(K==1){<br> g=static_cast<unsigned char>(ceil( 255.0*dct[++i]/maxdct) );<br>
}else{<br> real s=0;<br><br> for(P21::index j=0;j<K;++j) s+=dct[++i];<br><br> g=static_cast<unsigned char>(ceil( 255.0/K*s/maxdct ));<br> }<br> gui->_DCcoeffs.SetBrush(recFrame::GRAYMAP[ g ] );<br>
gui->_DCcoeffs.SetPen(recFrame::GRAYMAP[ g ] );<br> gui->_DCcoeffs.DrawRectangle( t,f,dt,df);<br><br> }<br><br>}<br><br>return 0;<br>}<br><br><br>The other recMain.h file is also attached for your kind help:<br>
/***************************************************************<br> * Name: recMain.h<br> * Purpose: Defines Application Frame<br> * Author: P21-UNI KL ()<br> * Created: 2008-02-21<br> * Copyright: P21-UNI KL ()<br>
* License:<br> **************************************************************/<br><br>#ifndef RECMAIN_H<br>#define RECMAIN_H<br><br>#include <wx/wx.h><br>#include "recApp.h"<br>#include "GUIFrame.h"<br>
<br>/***********/<br>#include "RtAudio.h"<br>#include<cassert><br><br>#include "names_P21.h"<br>#include "Signal.h"<br>#include "FEATEXTR.h"<br>/***********/<br><br>#include <fstream><br>
class recFrame: public GUIFrame<br>{<br> friend class FEATEXTR;<br> public:<br> recFrame(wxFrame *frame);<br> ~recFrame();<br> // declare CallBackFunction as friend<br> // in order to access GUI-handles<br>
friend int RtAudioInterface( void *outputBuffer,<br> void *inputBuffer,<br> unsigned int nBufferFrames,<br> double streamTime,<br> RtAudioStreamStatus status,<br>
void *callbackdata );<br><br><br> //const bool dct2matrix(const SILTT&);<br> private:<br> virtual void OnClose(wxCloseEvent& event);<br> virtual void OnQuit(wxCommandEvent& event);<br>
virtual void OnAbout(wxCommandEvent& event);<br> virtual void OnRecord(wxCommandEvent& event );//wxEVT_COMMAND_BUTTON_CLICKED &event)<br> virtual void OnChangeBufferSize(wxCommandEvent& event);//wxEVT_COMMAND_CHOICE_SELECTED<br>
<br> virtual void OnChoiceOf_Freq( wxCommandEvent& event); //wxEVT_COMMAND_CHOICE_SELECTED<br> virtual void OnEnter_CostPar( wxCommandEvent& event);<br> virtual void OnChoiceOf_CostFunc( wxCommandEvent& event);<br>
//virtual void showCoeffs( wxMouseEvent& event );<br> virtual void paint( wxMouseEvent& event);<br><br><br><br><br> bool _rec_status; // true=now recording, false=awaiting further commands<br>
RtAudio::StreamParameters _parameters;<br> enum CONTROL{START_STREAM=40,STOP_STREAM,OPEN_STREAM,CLOSE_STREAM};<br> void _stream(CONTROL);<br> RtAudio* _adc;<br> unsigned _sampleRate, _bufferFrames;<br>
wxClientDC& _DCcoeffs; // show DCT-coeffs<br> // some Brushes and Pens ???<br><br> static const wxColour GRAYMAP[256];<br> //static const wxCoord PLOTORIGIN;<br> P21::index _scale_x, _scale_y;<br>
<br> Signal* _x; // use empty constructor !!! that's the interface !!!<br> P21::index _calls; // counter for RtAudio-callbackfunction<br><br> Cost _cost;<br> real _costpar;<br><br><br> std::ofstream _COUT;<br>
<br> unsigned _fixed_analyze_size, _fb_counter;// _fb_counter=0,...,_fixed_analyze_size-1<br> real* _fixed_buffer;<br> RtAudio::DeviceInfo _deviceinfo;<br> FEATEXTR* _F;<br><br>};<br><br>#endif // RECMAIN_H<br>
<br><br>Thank you very much for your valuable time adn advice.<br><br>With sincere thanks,<br>Jui<br><br></div>