Added Recorded Time Display(feature request #733707) Added Stereo option Ensure stereo and bitrate controls are disabled while recordingmaster
@@ -70,12 +70,11 @@ string SpiralPlugin_GetGroupName() | |||
/////////////////////////////////////////////////////// | |||
DiskWriterPlugin::DiskWriterPlugin() : | |||
m_Recording(false) | |||
DiskWriterPlugin::DiskWriterPlugin() | |||
{ | |||
m_PluginInfo.Name="DiskWriter"; | |||
m_PluginInfo.Width=140; | |||
m_PluginInfo.Height=90; | |||
m_PluginInfo.Width=160; | |||
m_PluginInfo.Height=115; | |||
m_PluginInfo.NumInputs=3; | |||
m_PluginInfo.NumOutputs=0; | |||
m_PluginInfo.PortTips.push_back("Left Out"); | |||
@@ -83,9 +82,15 @@ m_Recording(false) | |||
m_PluginInfo.PortTips.push_back("Record Controller"); | |||
m_GUIArgs.BitsPerSample = 16; | |||
m_GUIArgs.Stereo = true; | |||
m_GUIArgs.Recording = false; | |||
m_GUIArgs.TimeRecorded = 0; | |||
m_AudioCH->RegisterData("Filename",ChannelHandler::INPUT,m_GUIArgs.Name,256); | |||
m_AudioCH->Register("BitsPerSample",&m_GUIArgs.BitsPerSample,ChannelHandler::INPUT); | |||
m_AudioCH->Register("Stereo",&m_GUIArgs.Stereo,ChannelHandler::INPUT); | |||
m_AudioCH->Register("TimeRecorded",&m_GUIArgs.TimeRecorded,ChannelHandler::OUTPUT); | |||
m_AudioCH->Register("Recording",&m_GUIArgs.Recording,ChannelHandler::OUTPUT); | |||
} | |||
DiskWriterPlugin::~DiskWriterPlugin() | |||
@@ -110,7 +115,7 @@ SpiralGUIType *DiskWriterPlugin::CreateGUI() | |||
void DiskWriterPlugin::Execute() | |||
{ | |||
if(m_Recording && m_Wav.IsOpen()) | |||
if(m_GUIArgs.Recording && m_Wav.IsOpen()) | |||
{ | |||
int on=0; | |||
float LeftBuffer[host->BUFSIZE], RightBuffer[host->BUFSIZE]; | |||
@@ -123,6 +128,7 @@ void DiskWriterPlugin::Execute() | |||
} | |||
m_Wav.Save(LeftBuffer, RightBuffer, host->BUFSIZE); | |||
m_GUIArgs.TimeRecorded = m_Wav.GetSize()/m_Wav.GetSamplerate(); | |||
} | |||
} | |||
@@ -139,11 +145,12 @@ void DiskWriterPlugin::ExecuteCommands() | |||
if (m_Wav.GetBitsPerSample() != m_GUIArgs.BitsPerSample) { | |||
m_Wav.SetBitsPerSample(m_GUIArgs.BitsPerSample); | |||
} | |||
m_Wav.Open(m_GUIArgs.Name,WavFile::WRITE, WavFile::STEREO); | |||
m_Wav.Open(m_GUIArgs.Name,WavFile::WRITE, (m_GUIArgs.Stereo)?(WavFile::STEREO):(WavFile::MONO)); | |||
m_GUIArgs.TimeRecorded = 0; | |||
break; | |||
case CLOSEWAV : m_Wav.Close(); break; | |||
case RECORD : m_Recording=true; break; | |||
case STOP : m_Recording=false; break; | |||
case RECORD : m_GUIArgs.Recording=true; break; | |||
case STOP : m_GUIArgs.Recording=false; break; | |||
default : break; | |||
} | |||
} | |||
@@ -41,12 +41,15 @@ public: | |||
{ | |||
char Name[256]; | |||
int BitsPerSample; | |||
bool Stereo; | |||
bool Recording; | |||
float TimeRecorded; | |||
}; | |||
private: | |||
GUIArgs m_GUIArgs; | |||
WavFile m_Wav; | |||
bool m_Recording; | |||
}; | |||
#endif |
@@ -41,7 +41,23 @@ SpiralPluginGUI(w,h,o,ch) | |||
m_32bits->labelsize(10); | |||
m_32bits->callback((Fl_Callback*)cb_32bits); | |||
Open = new Fl_Button(50, 20, 90, 20, "Open"); | |||
// 7 seg displays | |||
for (int dis=0; dis<4; dis++) { | |||
m_Display[dis] = new Fl_SevenSeg (50 + 27*dis, 20, 27, 38); | |||
m_Display[dis] -> bar_width (4); | |||
m_Display[dis] -> color (Info->SCOPE_FG_COLOUR); | |||
m_Display[dis] -> color2 (Info->SCOPE_BG_COLOUR); | |||
if (dis > 0 && dis % 2 == 0) m_Display[dis] -> dp (colon); | |||
add (m_Display[dis]); | |||
} | |||
m_Stereo = new Fl_Check_Button (105, 63, 10, 18, "Stereo"); | |||
m_Stereo->type (1); | |||
m_Stereo->value (1); | |||
m_Stereo->labelsize(12); | |||
m_Stereo->callback((Fl_Callback*)cb_Stereo); | |||
Open = new Fl_Button(0, 85, 75, 20, "Open"); | |||
Open->type(1); | |||
Open->box (FL_PLASTIC_UP_BOX); | |||
Open->color (Info->GUI_COLOUR); | |||
@@ -49,7 +65,7 @@ SpiralPluginGUI(w,h,o,ch) | |||
Open->labelsize(10); | |||
Open->callback((Fl_Callback*)cb_Open); | |||
Record = new Fl_Button(50, 60, 90, 20, "Record"); | |||
Record = new Fl_Button(85, 85, 75, 20, "Record"); | |||
Record->type(1); | |||
Record->box (FL_PLASTIC_UP_BOX); | |||
Record->color (Info->GUI_COLOUR); | |||
@@ -60,8 +76,35 @@ SpiralPluginGUI(w,h,o,ch) | |||
end(); | |||
} | |||
void DiskWriterPluginGUI::UpdateValues(SpiralPlugin *o) | |||
void DiskWriterPluginGUI::Update() | |||
{ | |||
float t=m_GUICH->GetFloat ("TimeRecorded"); | |||
bool recording=m_GUICH->GetBool ("Recording"); | |||
if (recording) | |||
{ | |||
m_16bits->deactivate(); | |||
m_24bits->deactivate(); | |||
m_32bits->deactivate(); | |||
m_Stereo->deactivate(); | |||
} | |||
else | |||
{ | |||
m_16bits->activate(); | |||
m_24bits->activate(); | |||
m_32bits->activate(); | |||
m_Stereo->activate(); | |||
} | |||
m_Display[3]->value ((int)t % 10); | |||
m_Display[2]->value ((int)(t/10) % 6); | |||
m_Display[1]->value ((int)(t/60) % 10); | |||
m_Display[0]->value ((int)(t/600) % 10); | |||
redraw(); | |||
} | |||
void DiskWriterPluginGUI::UpdateValues (SpiralPlugin *o) { | |||
} | |||
//// Callbacks //// | |||
@@ -123,6 +166,13 @@ inline void DiskWriterPluginGUI::cb_32bits_i(Fl_Button* o, void* v) | |||
void DiskWriterPluginGUI::cb_32bits(Fl_Button* o, void* v) | |||
{ ((DiskWriterPluginGUI*)(o->parent()))->cb_32bits_i(o,v); } | |||
inline void DiskWriterPluginGUI::cb_Stereo_i(Fl_Button* o, void* v) | |||
{ | |||
m_GUICH->Set("Stereo",o->value()); | |||
} | |||
void DiskWriterPluginGUI::cb_Stereo(Fl_Button* o, void* v) | |||
{ ((DiskWriterPluginGUI*)(o->parent()))->cb_Stereo_i(o,v); } | |||
const string DiskWriterPluginGUI::GetHelpText(const string &loc){ | |||
return string("") | |||
+ "One way of recording your creations to disk. First open a file\n" | |||
@@ -16,11 +16,14 @@ | |||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
*/ | |||
#include "DiskWriterPlugin.h" | |||
#include <FL/Fl.H> | |||
#include <FL/Fl_Button.H> | |||
#include "DiskWriterPlugin.h" | |||
#include <FL/Fl_Check_Button.H> | |||
#include "../SpiralPluginGUI.h" | |||
#include "../Widgets/Fl_LED_Button.H" | |||
#include "../Widgets/Fl_SevenSeg.H" | |||
#ifndef DISK_WRITER_GUI_H | |||
#define DISK_WRITER_GUI_H | |||
@@ -30,7 +33,8 @@ class DiskWriterPluginGUI : public SpiralPluginGUI | |||
public: | |||
DiskWriterPluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch, const HostInfo *Info); | |||
virtual void UpdateValues(SpiralPlugin *o); | |||
virtual void Update (); | |||
virtual void UpdateValues (SpiralPlugin *o); | |||
protected: | |||
const std::string GetHelpText(const std::string &loc); | |||
@@ -44,6 +48,10 @@ private: | |||
Fl_LED_Button *m_24bits; | |||
Fl_LED_Button *m_32bits; | |||
Fl_Check_Button *m_Stereo; | |||
Fl_SevenSeg *m_Display[4]; | |||
//// Callbacks //// | |||
inline void cb_Record_i(Fl_Button* o, void* v); | |||
@@ -57,6 +65,9 @@ private: | |||
static void cb_24bits(Fl_Button* o, void* v); | |||
inline void cb_32bits_i(Fl_Button* o, void* v); | |||
static void cb_32bits(Fl_Button* o, void* v); | |||
inline void cb_Stereo_i(Fl_Button* o, void* v); | |||
static void cb_Stereo(Fl_Button* o, void* v); | |||
}; | |||
#endif |
@@ -46,6 +46,7 @@ HEADERS = DiskWriterPlugin.h \ | |||
../../Sample.h \ | |||
../../RiffWav.h \ | |||
../Widgets/Fl_LED_Button.H \ | |||
../Widgets/Fl_SevenSeg.H \ | |||
../../../GUI/Widgets/SpiralGUI.H | |||
SOURCES = DiskWriterPlugin.C \ | |||
DiskWriterPluginGUI.C \ | |||
@@ -55,6 +56,7 @@ SOURCES = DiskWriterPlugin.C \ | |||
../../Sample.C \ | |||
../../RiffWav.C \ | |||
../Widgets/Fl_LED_Button.cxx \ | |||
../Widgets/Fl_SevenSeg.cxx \ | |||
../../../GUI/Widgets/SpiralGUI.C | |||
OBJECTS = DiskWriterPlugin.o \ | |||
DiskWriterPluginGUI.o \ | |||
@@ -64,6 +66,7 @@ OBJECTS = DiskWriterPlugin.o \ | |||
../../Sample.o \ | |||
../../RiffWav.o \ | |||
../Widgets/Fl_LED_Button.o \ | |||
../Widgets/Fl_SevenSeg.o \ | |||
../../../GUI/Widgets/SpiralGUI.o | |||
INTERFACES = | |||
UICDECLS = | |||
@@ -139,6 +142,9 @@ install: | |||
../../../GUI/Widgets/SpiralGUI.o: ../../../GUI/Widgets/SpiralGUI.C \ | |||
../../../GUI/Widgets/SpiralGUI.H | |||
../Widgets/Fl_SevenSeg.o: ../Widgets/Fl_SevenSeg.cxx \ | |||
../Widgets/Fl_SevenSeg.H | |||
../../Sample.o: ../../Sample.C \ | |||
../../Sample.h | |||