├── svgo.res ├── rabiscoscopio.res ├── garoa ├── garoa_logo.wav └── garoa_logo.svg ├── release └── rabiscoscopio.zip ├── rabiscoscopio.cpp ├── uMain.h ├── test svg ├── teste2.svg ├── teste4.svg └── teste5.svg ├── rabiscoscopio.cbproj └── uMain.cpp /svgo.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aporto/rabiscoscopio/HEAD/svgo.res -------------------------------------------------------------------------------- /rabiscoscopio.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aporto/rabiscoscopio/HEAD/rabiscoscopio.res -------------------------------------------------------------------------------- /garoa/garoa_logo.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aporto/rabiscoscopio/HEAD/garoa/garoa_logo.wav -------------------------------------------------------------------------------- /release/rabiscoscopio.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aporto/rabiscoscopio/HEAD/release/rabiscoscopio.zip -------------------------------------------------------------------------------- /rabiscoscopio.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | #include 6 | //--------------------------------------------------------------------------- 7 | USEFORM("uMain.cpp", frmMain); 8 | //--------------------------------------------------------------------------- 9 | WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) 10 | { 11 | try 12 | { 13 | Application->Initialize(); 14 | Application->MainFormOnTaskBar = true; 15 | Application->CreateForm(__classid(TfrmMain), &frmMain); 16 | Application->Run(); 17 | } 18 | catch (Exception &exception) 19 | { 20 | Application->ShowException(&exception); 21 | } 22 | catch (...) 23 | { 24 | try 25 | { 26 | throw Exception(""); 27 | } 28 | catch (Exception &exception) 29 | { 30 | Application->ShowException(&exception); 31 | } 32 | } 33 | return 0; 34 | } 35 | //--------------------------------------------------------------------------- 36 | -------------------------------------------------------------------------------- /uMain.h: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | #ifndef uMainH 3 | #define uMainH 4 | //-------------------------------------------------------------------------------------------------- 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | //-------------------------------------------------------------------------------------------------- 22 | 23 | struct TVecPoint { 24 | double x; 25 | double y; 26 | }; 27 | 28 | //-------------------------------------------------------------------------------------------------- 29 | 30 | #pragma pack(push, 1) 31 | 32 | struct TWaveHeader { 33 | char chunkId[4]; 34 | unsigned int chunkSize; 35 | char format[4]; 36 | char subChunk1Id[4]; 37 | unsigned int subChunk1Size; 38 | unsigned short audioFormat; 39 | unsigned short numChannels; 40 | unsigned int sampleRate; 41 | unsigned int byteRate; 42 | unsigned short blockAlign; 43 | unsigned short bitsPerSample; 44 | char subChunk2Id[4]; 45 | unsigned int subChunk2Size; 46 | }; 47 | 48 | #pragma pack(pop) 49 | 50 | //-------------------------------------------------------------------------------------------------- 51 | 52 | using namespace std; 53 | 54 | //-------------------------------------------------------------------------------------------------- 55 | 56 | class TfrmMain : public TForm 57 | { 58 | __published: // IDE-managed Components 59 | TPanel *pnlDraw; 60 | TPanel *pnlAxisX; 61 | TPanel *Panel3; 62 | TSpeedButton *SpeedButton1; 63 | TImage *imgMain; 64 | TImage *imgY; 65 | TPanel *pnlAxisY; 66 | TImage *imgX; 67 | TOpenDialog *openDialog; 68 | TProgressBar *progress; 69 | TEdit *ebDuration; 70 | TEdit *ebCycles; 71 | TLabel *lblDone; 72 | TSpeedButton *SpeedButton2; 73 | TLabel *Label2; 74 | TLabel *Label3; 75 | TLabel *Label1; 76 | TLabel *Label4; 77 | TButton *Button1; 78 | void __fastcall SpeedButton1Click(TObject *Sender); 79 | void __fastcall FormCreate(TObject *Sender); 80 | void __fastcall FormResize(TObject *Sender); 81 | void __fastcall FormActivate(TObject *Sender); 82 | void __fastcall SpeedButton2Click(TObject *Sender); 83 | void __fastcall Button1Click(TObject *Sender); 84 | private: // User declarations 85 | bool __fastcall LoadFile(AnsiString fileName); 86 | void __fastcall DecodeLine(AnsiString line, bool relative); 87 | void __fastcall DrawPoints(void); 88 | void __fastcall NormalizePoints(); 89 | void __fastcall BreakAxis(); 90 | void __fastcall WriteWaveData(); 91 | void __fastcall WriteWaveFile(AnsiString fileName); 92 | void __fastcall ProcessFile(AnsiString file); 93 | vector points; 94 | vector axis_x; 95 | vector axis_y; 96 | float sampleRate; 97 | double duration; 98 | //int cycles; 99 | int fileLength; 100 | //bool calculating; 101 | public: // User declarations 102 | __fastcall TfrmMain(TComponent* Owner); 103 | }; 104 | 105 | //-------------------------------------------------------------------------------------------------- 106 | 107 | extern PACKAGE TfrmMain *frmMain; 108 | 109 | //-------------------------------------------------------------------------------------------------- 110 | 111 | //-------------------------------------------------------------------------------------------------- 112 | #endif 113 | //-------------------------------------------------------------------------------------------------- 114 | -------------------------------------------------------------------------------- /test svg/teste2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 54 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /test svg/teste4.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 54 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /test svg/teste5.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 54 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /rabiscoscopio.cbproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | {4D0B2211-B42A-4DB0-A651-B75A7F9074A7} 4 | 12.0 5 | rabiscoscopio.cpp 6 | Debug 7 | 8 | 9 | true 10 | 11 | 12 | true 13 | Base 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | D:\Projetos\Eletronica\Osciloscopio\rabiscoscopio\obj 23 | D:\Projetos\Eletronica\Osciloscopio\rabiscoscopio\obj 24 | D:\Projetos\Eletronica\Osciloscopio\rabiscoscopio\obj 25 | D:\Projetos\Eletronica\Osciloscopio\rabiscoscopio\release 26 | exe 27 | true 28 | rtl.bpi;vcl.bpi 29 | vclx.bpi;vcl.bpi;dbrtl.bpi;Rave76VCL.bpi;bdertl.bpi;rtl.bpi;bcbie.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;vcldb.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;TeeUI.bpi;TeeDB.bpi;Tee.bpi;adortl.bpi;vclib.bpi;ibxpress.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;inet.bpi;intrawebdb_100_120.bpi;Intraweb_100_120.bpi;vclie.bpi;websnap.bpi;webdsnap.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;vclribbon.bpi;dbexpress.bpi;DbxCommonDriver.bpi;DataSnapIndy10ServerTransport.bpi;DataSnapProviderClient.bpi;DataSnapServer.bpi;DbxClientDriver.bpi;DBXInterBaseDriver.bpi;DBXMySQLDriver.bpi;dbxcds.bpi;DBXSybaseASEDriver.bpi;DBXSybaseASADriver.bpi;DBXOracleDriver.bpi;DBXMSSQLDriver.bpi;DBXInformixDriver.bpi;DBXDb2Driver.bpi;advmemopkgC2009.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD12R.bpi;JvSystemD12R.bpi;JvStdCtrlsD12R.bpi;JvAppFrmD12R.bpi;JvBandsD12R.bpi;JvDBD12R.bpi;JvDlgsD12R.bpi;JvBDED12R.bpi;JvCmpD12R.bpi;JvCryptD12R.bpi;JvCtrlsD12R.bpi;JvCustomD12R.bpi;JvDockingD12R.bpi;JvDotNetCtrlsD12R.bpi;JvEDID12R.bpi;JvGlobusD12R.bpi;JvHMID12R.bpi;JvInterpreterD12R.bpi;JvJansD12R.bpi;JvManagedThreadsD12R.bpi;JvMMD12R.bpi;JvNetD12R.bpi;JvPageCompsD12R.bpi;JvPluginD12R.bpi;JvPrintPreviewD12R.bpi;JvRuntimeDesignD12R.bpi;JvTimeFrameworkD12R.bpi;JvValidatorsD12R.bpi;JvWizardD12R.bpi;JvXPCtrlsD12R.bpi;ets_pack.bpi;bsfcb2009.bpi;Graphic32_CB2009.bpi;skinpackcb2009.bpi 30 | rtl.lib;vcl.lib 31 | CppVCLApplication 32 | JPHNE 33 | NO_STRICT 34 | true 35 | true 36 | svgo;$(CG_BOOST_ROOT)\boost\tr1\tr1;$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;$(CG_BOOST_ROOT) 37 | svgo;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk 38 | false 39 | true 40 | 41 | 42 | false 43 | true 44 | false 45 | true 46 | _DEBUG;$(Defines) 47 | false 48 | Debug 49 | true 50 | None 51 | DEBUG 52 | true 53 | true 54 | true 55 | $(BDS)\lib\debug;$(ILINK_LibraryPath) 56 | true 57 | Full 58 | true 59 | 60 | 61 | NDEBUG;$(Defines) 62 | Release 63 | $(BDS)\lib\release;$(ILINK_LibraryPath) 64 | None 65 | 66 | 67 | 68 | 0 69 | 70 | 71 | rabiscoscopio.res 72 | 1 73 | 74 | 75 |
frmMain
76 | uMain.h 77 | 2 78 |
79 | 80 | 81 | Base 82 | 83 | 84 | Cfg_2 85 | Base 86 | 87 | 88 | Cfg_1 89 | Base 90 | 91 |
92 | 93 | 94 | CPlusPlusBuilder.Personality.12 95 | CppVCLApplication 96 | 97 | 98 | 99 | rabiscoscopio.cpp 100 | 101 | 102 | False 103 | False 104 | 1 105 | 0 106 | 0 107 | 0 108 | False 109 | False 110 | False 111 | False 112 | False 113 | 1046 114 | 1252 115 | 116 | 117 | 118 | 119 | 1.0.0.0 120 | 121 | 122 | 123 | 124 | 125 | 1.0.0.0 126 | 127 | 128 | 129 | 130 | 131 | 132 | D:\Users\Alex\Desktop\teste5.svg 133 | 134 | False 135 | 136 | 137 | 138 | 139 | 140 | 141 | False 142 | 143 | False 144 | 145 | True 146 | False 147 | 148 | 149 | False 150 | True 151 | True 152 | 153 | 154 | JCL Debug IDE extension 155 | JCL Project Analyzer 156 | JCL Open and Save IDE dialogs with favorite folders 157 | JCL Debug Window of XMM registers 158 | CodeGear C++Builder Office 2000 Servers Package 159 | CodeGear C++Builder Office XP Servers Package 160 | 161 | 162 | 163 | 12 164 | 165 |
166 | -------------------------------------------------------------------------------- /uMain.cpp: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | 3 | 4 | #pragma hdrstop 5 | 6 | #include "uMain.h" 7 | 8 | //-------------------------------------------------------------------------------------------------- 9 | 10 | #pragma resource "*.dfm" 11 | TfrmMain *frmMain; 12 | 13 | //-------------------------------------------------------------------------------------------------- 14 | 15 | __fastcall TfrmMain::TfrmMain(TComponent* Owner) 16 | : TForm(Owner) 17 | { 18 | } 19 | 20 | //-------------------------------------------------------------------------------------------------- 21 | 22 | void __fastcall TfrmMain::SpeedButton1Click(TObject *Sender) 23 | { 24 | if (openDialog->Execute()) { 25 | ProcessFile(openDialog->FileName); 26 | } 27 | } 28 | 29 | //-------------------------------------------------------------------------------------------------- 30 | 31 | bool __fastcall TfrmMain::LoadFile(AnsiString fileName) 32 | { 33 | TStringList * file = new TStringList; 34 | 35 | if (FileExists(fileName) == false) { 36 | ShowMessage("Erro ao carregar o arquivi:\n" + fileName); 37 | return false; 38 | } 39 | 40 | openDialog->FileName = fileName; 41 | 42 | file->LoadFromFile(fileName); 43 | 44 | if (file->Count < 1) { 45 | return false; 46 | } 47 | 48 | AnsiString line; 49 | do { 50 | line = file->Strings[0]; 51 | file->Delete(0); 52 | } while ((file->Count > 0) && (line.Pos("Count < 1) { 55 | return false; 56 | } 57 | 58 | line = file->Strings[0]; 59 | line = line.LowerCase(); 60 | bool relative = true; 61 | int p = line.Pos("d=\"m "); 62 | if (p == 0) { 63 | p = line.Pos("d=\"M "); 64 | relative = false; 65 | } 66 | while (p == 0) { 67 | file->Delete(0); 68 | line = file->Strings[0]; 69 | p = line.Pos("d=\"m "); 70 | relative = true; 71 | if (p == 0) { 72 | p = line.Pos("d=\"M "); 73 | relative = false; 74 | } 75 | } 76 | 77 | if (p > 0) { 78 | line = line.Delete(1, p + 4); 79 | } 80 | 81 | if (line.Pos("\"") == 0) { 82 | return false; 83 | } 84 | 85 | line = line.Delete(line.Pos("\""), line.Length()); 86 | 87 | DecodeLine(line, relative); 88 | 89 | NormalizePoints(); 90 | 91 | BreakAxis(); 92 | 93 | DrawPoints(); 94 | 95 | delete file; 96 | 97 | Application->ProcessMessages(); 98 | 99 | return true; 100 | } 101 | 102 | //-------------------------------------------------------------------------------------------------- 103 | 104 | /*void __fastcall TfrmMain::BreakAxis() 105 | { 106 | double totalx = 0; 107 | axis_x.clear(); 108 | axis_y.clear(); 109 | 110 | int psize = points.size()-1; 111 | 112 | for (int i = 0; i < psize; i++) { 113 | totalx += abs((long)(points.at(i).x - points.at(i+1).x)); 114 | } 115 | 116 | double lowerDeltaT = 10000000; 117 | double last_x = 0; 118 | 119 | for (int i = 0; i < psize; i++) { 120 | double x1, x2, y1, y2; 121 | x1 = points.at(i).x; 122 | x2 = points.at(i+1).x; 123 | y1 = points.at(i).y; 124 | y2 = points.at(i+1).y; 125 | 126 | double dnp; 127 | if (x2>x1) dnp = x2-x1; else dnp = x1-x2; 128 | 129 | //int np = (dnp/totalx + 1) * double(sampleRate) / totalx+1; 130 | int np = (double(duration) * dnp / totalx) + 1;// * double(sampleRate) + 1; 131 | for (int j = 1; j <= np; j++) { 132 | double r = double(j) / double(np); 133 | double y = - (y1 + (y2 - y1) * r); 134 | double x = (x1 + (x2 - x1) * r); // x vira negativo qdo vira y, pois o eixo y eh invertido 135 | axis_x.push_back(x); 136 | axis_y.push_back(y); 137 | 138 | if ((x - last_x) < lowerDeltaT) { 139 | lowerDeltaT = x - last_x; 140 | } 141 | 142 | last_x = x; 143 | } 144 | } 145 | 146 | double d1 = axis_y.size(); 147 | double d2 = sampleRate; 148 | double d3 = cycles; 149 | int t = (d1 / d2); 150 | lblPointCount->Caption = IntToStr(t); 151 | lblSmallerDeltaX->Caption = FloatToStr(lowerDeltaT * 1000) + " ms"; 152 | } */ 153 | 154 | //-------------------------------------------------------------------------------------------------- 155 | 156 | void __fastcall TfrmMain::BreakAxis() 157 | { 158 | double totalx = 0; 159 | axis_x.clear(); 160 | axis_y.clear(); 161 | 162 | int psize = points.size()-1; 163 | 164 | // totalx holds the full length (sum of all "x" segments) 165 | for (int i = 0; i < psize; i++) { 166 | double delta; 167 | if (points.at(i).x > points.at(i+1).x) { 168 | delta = points.at(i).x - points.at(i+1).x; 169 | } else { 170 | delta = points.at(i+1).x - points.at(i).x; 171 | } 172 | totalx += delta; 173 | } 174 | 175 | // "times" hold all "x" values converted to real-time 176 | vector times; 177 | times.push_back(0.0); 178 | for (int i = 0; i < psize; i++) { 179 | double delta; 180 | if (points.at(i).x > points.at(i+1).x) { 181 | delta = points.at(i).x - points.at(i+1).x; 182 | } else { 183 | delta = points.at(i+1).x - points.at(i).x; 184 | } 185 | double time = (delta/totalx) * duration + times.at(i); 186 | times.push_back(time); 187 | } 188 | 189 | unsigned int numberOfPoints = sampleRate * duration; 190 | int idx = 0; 191 | double timeStep = 1.0 / sampleRate; 192 | double time = 0.0; 193 | double grad = 0.0; 194 | double x1 = points.at(idx).x; 195 | double x2 = points.at(idx+1).x ; 196 | double y1 = points.at(idx).y; 197 | double y2 = points.at(idx+1).y; 198 | double lim_inf = times.at(idx); 199 | double lim_sup = times.at(idx+1); 200 | double x, y; 201 | int k = times.size(); 202 | for (unsigned int i = 0; i < numberOfPoints; i++) { 203 | if (abs(lim_sup - lim_inf) < 0.00001) { 204 | grad = 0; 205 | } else { 206 | grad = ((time - lim_inf) / (lim_sup - lim_inf)); 207 | } 208 | double delta = y2-y1; 209 | if (abs(delta) > 0.00001) { 210 | y = y1 + grad * delta; 211 | } else { 212 | y = y1; 213 | } 214 | delta = x2-x1; 215 | if (abs(delta) > 0.00001) { 216 | x = x1 + grad * delta; 217 | } else { 218 | x = x1; 219 | } 220 | //double x = points.at(idx + 1).x + grad * (points.at(idx + 1).x - points.at(i).x); 221 | 222 | axis_x.push_back(x); 223 | //axis_y.push_back(-(y)); 224 | axis_y.push_back(y); 225 | 226 | time = time + timeStep; 227 | if (time > lim_sup) { 228 | idx++; 229 | if (idx >= psize) { 230 | if (i < numberOfPoints - 10) { 231 | ShowMessage("Ops! Deu pau na interpolacao!"); 232 | } 233 | break; 234 | } 235 | x1 = points.at(idx).x; 236 | x2 = points.at(idx+1).x ; 237 | y1 = points.at(idx).y; 238 | y2 = points.at(idx+1).y; 239 | lim_inf = times.at(idx); 240 | lim_sup = times.at(idx+1); 241 | } 242 | } 243 | 244 | /*double d1 = axis_y.size(); 245 | double d2 = sampleRate; 246 | double d3 = cycles; 247 | int t = (d1 / d2); 248 | lblPointCount->Caption = IntToStr(t); 249 | lblSmallerDeltaX->Caption = FloatToStrF(timeStep * 1000, ffFixed, 5, 3) + " ms";*/ 250 | } 251 | 252 | //-------------------------------------------------------------------------------------------------- 253 | 254 | void __fastcall TfrmMain::NormalizePoints() 255 | { 256 | double minx = 10000000; 257 | double maxx = -10000000; 258 | double miny = 10000000; 259 | double maxy = -10000000; 260 | 261 | for (unsigned int i = 0; i < points.size(); i++) { 262 | if (points.at(i).x > maxx) { 263 | maxx = points.at(i).x; 264 | } 265 | if (points.at(i).y > maxy) { 266 | maxy = points.at(i).y; 267 | } 268 | if (points.at(i).x < minx) { 269 | minx = points.at(i).x; 270 | } 271 | if (points.at(i).y < miny) { 272 | miny = points.at(i).y; 273 | } 274 | } 275 | 276 | double w = maxx - minx; 277 | double h = maxy - miny; 278 | double zerox = w / 2; 279 | double zeroy = h / 2; 280 | 281 | for (unsigned int i = 0; i < points.size(); i++) { 282 | double x = points.at(i).x; 283 | double y = points.at(i).y; 284 | x = (x - minx) * 80 / w - 50 + 10; 285 | y = (y - miny) * 80 / h - 50 + 10; 286 | points.at(i).x = x; 287 | points.at(i).y = y; 288 | } 289 | } 290 | 291 | //-------------------------------------------------------------------------------------------------- 292 | 293 | void __fastcall TfrmMain::DecodeLine(AnsiString line, bool relative) 294 | { 295 | points.clear(); 296 | int p = line.Pos(" "); 297 | bool first = true; 298 | TVecPoint last = {0, 0}; 299 | while (line.Length() > 0) { 300 | AnsiString mline = line.SubString(1, p-1); 301 | line = line.Delete(1, mline.Length() + 1); 302 | 303 | int pv = mline.Pos(","); 304 | 305 | if (pv > 0) { 306 | AnsiString xs = mline.SubString(0, pv-1); 307 | AnsiString ys = mline.SubString(pv+1, mline.Length()); 308 | 309 | TVecPoint point; 310 | try { 311 | point.x = xs.ToDouble(); 312 | point.y = ys.ToDouble(); 313 | } catch (...) { 314 | point.x = 0; 315 | point.y = 0; 316 | } 317 | 318 | if (relative) { 319 | point.x += last.x; 320 | point.y += last.y; 321 | } 322 | memcpy(&last, &point, sizeof(TVecPoint)); 323 | 324 | points.push_back(point); 325 | } else { 326 | if (mline == "z") { 327 | points.push_back(points.at(0)); 328 | } 329 | 330 | if (mline == "l") { 331 | relative = true; 332 | } 333 | 334 | if (mline.UpperCase() == mline) { 335 | relative = false; 336 | } 337 | } 338 | 339 | p = line.Pos(" "); 340 | if (p == 0) { 341 | p = line.Length(); 342 | } 343 | first = false; 344 | } 345 | } 346 | 347 | //-------------------------------------------------------------------------------------------------- 348 | 349 | void __fastcall TfrmMain::DrawPoints(void) 350 | { 351 | 352 | double w = pnlDraw->Width; 353 | double h = pnlDraw->Height; 354 | TCanvas * can = imgMain->Picture->Bitmap->Canvas; 355 | imgMain->Picture->Bitmap->Width = w; 356 | imgMain->Picture->Bitmap->Height = h; 357 | can->Pen->Color = clBlack; 358 | can->Brush->Color = clBlack; 359 | can->FillRect(TRect(0, 0, w, h)); 360 | 361 | can->Pen->Color = clGreen; 362 | can->MoveTo(0, h/2); 363 | can->LineTo(w, h/2); 364 | can->MoveTo(w/2, 0); 365 | can->LineTo(w/2, h); 366 | can->Pen->Color = clLime; 367 | double x, y; 368 | if (points.size() > 0) { 369 | x = points.at(0).x; 370 | x = x * w/100 + w/2; 371 | y = points.at(0).y; 372 | y = y * h/100 + h/2; 373 | can->MoveTo(x, y); 374 | for (unsigned int i = 1; i < points.size(); i++) { 375 | x = points.at(i).x; 376 | x = x * w/100 + w/2; 377 | y = points.at(i).y; 378 | y = y * h/100 + h/2; 379 | can->LineTo(x, y); 380 | } 381 | } 382 | 383 | // axis y 384 | w = pnlAxisY->Width; 385 | h = pnlAxisY->Height; 386 | can = imgY->Picture->Bitmap->Canvas; 387 | imgY->Picture->Bitmap->Width = w; 388 | imgY->Picture->Bitmap->Height = h; 389 | can->Pen->Color = clBlack; 390 | can->Brush->Color = clBlack; 391 | can->FillRect(TRect(0, 0, w, h)); 392 | 393 | can->Pen->Color = clGreen; 394 | can->MoveTo(0, h/2); 395 | can->LineTo(w, h/2); 396 | can->MoveTo(w/2, 0); 397 | can->LineTo(w/2, h); 398 | can->Pen->Color = clLime; 399 | if (axis_y.size() > 0) { 400 | y = axis_y.at(0); 401 | y = y * h/200 + h/2; 402 | x = 0; 403 | can->MoveTo(x, y); 404 | for (unsigned int i = 1; i < axis_y.size(); i++) { 405 | y = axis_y.at(i); 406 | y = /*h - */(y * h/200 + h/2); 407 | x = i * w / axis_y.size(); 408 | can->LineTo(x, y); 409 | } 410 | } 411 | 412 | // axis x 413 | w = pnlAxisX->Width; 414 | h = pnlAxisX->Height; 415 | can = imgX->Picture->Bitmap->Canvas; 416 | imgX->Picture->Bitmap->Width = w; 417 | imgX->Picture->Bitmap->Height = h; 418 | can->Pen->Color = clBlack; 419 | can->Brush->Color = clBlack; 420 | can->FillRect(TRect(0, 0, w, h)); 421 | 422 | can->Pen->Color = clGreen; 423 | can->MoveTo(0, h/2); 424 | can->LineTo(w, h/2); 425 | can->MoveTo(w/2, 0); 426 | can->LineTo(w/2, h); 427 | can->Pen->Color = clLime; 428 | if (axis_x.size() > 0) { 429 | y = axis_x.at(0); 430 | y = y * h/200 + h/2; 431 | x = 0; 432 | can->MoveTo(x, y); 433 | for (unsigned int i = 1; i < axis_x.size(); i++) { 434 | y = axis_x.at(i); 435 | y = h - (y * h/200 + h/2); 436 | x = i * w / axis_x.size(); 437 | can->LineTo(x, y); 438 | } 439 | } 440 | } 441 | 442 | //-------------------------------------------------------------------------------------------------- 443 | 444 | void __fastcall TfrmMain::FormCreate(TObject *Sender) 445 | { 446 | DecimalSeparator = '.'; 447 | sampleRate = 48000;//StrToInt(ebSampleRate->Text); 448 | duration = StrToFloat(ebDuration->Text); 449 | fileLength = /*cycles = */StrToInt(ebCycles->Text); 450 | 451 | } 452 | 453 | //-------------------------------------------------------------------------------------------------- 454 | 455 | void __fastcall TfrmMain::WriteWaveFile(AnsiString fileName) 456 | { 457 | unsigned int numSamples = 0; 458 | unsigned int dataSize = 0; 459 | TWaveHeader header; 460 | 461 | memcpy(header.chunkId, "RIFF", 4); 462 | memcpy(header.format, "WAVE", 4); 463 | 464 | memcpy(header.subChunk1Id, "fmt ", 4); 465 | header.subChunk1Size = 16; 466 | header.audioFormat = 1; 467 | header.numChannels = 2; 468 | header.sampleRate = sampleRate; 469 | header.bitsPerSample = 16; 470 | header.byteRate = header.sampleRate * header.numChannels * (header.bitsPerSample/8); 471 | header.blockAlign = header.numChannels * (header.bitsPerSample/8); 472 | 473 | memcpy(header.subChunk2Id, "data", 4); 474 | 475 | char buffer[100]; 476 | ofstream file (fileName.c_str(), ios::out | ios::binary); 477 | 478 | int sz = sizeof(TWaveHeader); 479 | file.write ((char *)&header, sz); 480 | int total = axis_y.size(); 481 | int cycles = fileLength / duration; 482 | int pTotal = cycles * total; 483 | int prog = 0; 484 | for (int j = 0; j < cycles; j++) { 485 | for (int i = 0; i < total; i++) { 486 | double vy = axis_y.at(i); 487 | double vx = axis_x.at(i); 488 | short sample[2]; 489 | sample[0] = (short) (vy / 100 * 32767); 490 | sample[1] = (short) (vx / 100 * 32767); 491 | file.write((char *)sample, 4); 492 | numSamples ++; 493 | dataSize += 4; 494 | 495 | prog++; 496 | int p = prog * 100 / pTotal; 497 | if (progress->Position != p) { 498 | progress->Position = p; 499 | } 500 | } 501 | } 502 | file.seekp(0); 503 | header.subChunk2Size = numSamples * header.numChannels * header.bitsPerSample/8; 504 | header.chunkSize = 28 + 8 + dataSize; 505 | file.write ((char *)&header, sizeof(TWaveHeader)); 506 | file.close(); 507 | progress->Position = 0; 508 | } 509 | 510 | //-------------------------------------------------------------------------------------------------- 511 | 512 | void __fastcall TfrmMain::FormResize(TObject *Sender) 513 | { 514 | DrawPoints(); 515 | Application->ProcessMessages(); 516 | } 517 | 518 | //-------------------------------------------------------------------------------------------------- 519 | 520 | void __fastcall TfrmMain::FormActivate(TObject *Sender) 521 | { 522 | if (FileExists(ParamStr(1))) { 523 | ProcessFile(ParamStr(1)); 524 | } 525 | } 526 | 527 | //-------------------------------------------------------------------------------------------------- 528 | 529 | void __fastcall TfrmMain::ProcessFile(AnsiString file) 530 | { 531 | lblDone->Caption = "Processing..."; 532 | Application->ProcessMessages(); 533 | 534 | //sampleRate = StrToInt(ebSampleRate->Text); 535 | duration = StrToFloat(ebDuration->Text); 536 | fileLength = StrToInt(ebCycles->Text); 537 | 538 | //ebSampleRate->Text = IntToStr((int)sampleRate); 539 | ebDuration->Text = FloatToStr(duration); 540 | ebCycles->Text = IntToStr(fileLength); 541 | 542 | if (LoadFile(file)) { 543 | AnsiString wave = file; 544 | wave = wave.Delete(wave.Length() - 3, 4) + ".wav"; 545 | WriteWaveFile(wave); 546 | } else { 547 | ShowMessage("Deu pau"); 548 | } 549 | 550 | lblDone->Caption = "Done"; 551 | Application->ProcessMessages(); 552 | } 553 | 554 | //-------------------------------------------------------------------------------------------------- 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | void __fastcall TfrmMain::SpeedButton2Click(TObject *Sender) 563 | { 564 | ProcessFile(openDialog->FileName); 565 | } 566 | //--------------------------------------------------------------------------- 567 | 568 | void __fastcall TfrmMain::Button1Click(TObject *Sender) 569 | { 570 | AnsiString cmd = "http://dalpix.com/rabiscoscopio"; 571 | 572 | ShellExecuteA(Handle, "open", cmd.c_str(), NULL, NULL, SW_SHOWNORMAL); 573 | // WinExec(cmd.c_str(), SW_SHOW); 574 | } 575 | //--------------------------------------------------------------------------- 576 | 577 | -------------------------------------------------------------------------------- /garoa/garoa_logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 66 | 69 | 74 | 77 | 81 | 85 | 89 | 93 | 97 | 101 | 105 | 109 | 113 | 117 | 121 | 125 | 129 | 133 | 137 | 141 | 145 | 149 | 153 | 157 | 161 | 165 | 169 | 173 | 177 | 181 | 185 | 189 | 193 | 197 | 201 | 205 | 209 | 213 | 217 | 221 | 225 | 229 | 233 | 237 | 241 | 245 | 249 | 253 | 257 | 261 | 265 | 269 | 273 | 277 | 281 | 285 | 289 | 293 | 297 | 301 | 305 | 309 | 313 | 317 | 321 | 325 | 329 | 333 | 337 | 341 | 345 | 349 | 353 | 357 | 361 | 365 | 369 | 373 | 377 | 381 | 385 | 389 | 393 | 397 | 401 | 405 | 409 | 413 | 417 | 421 | 425 | 429 | 433 | 437 | 441 | 445 | 449 | 453 | 457 | 461 | 465 | 469 | 473 | 477 | 481 | 485 | 489 | 493 | 497 | 501 | 505 | 509 | 513 | 517 | 521 | 525 | 529 | 533 | 537 | 541 | 545 | 549 | 553 | 557 | 561 | 565 | 569 | 573 | 574 | 579 | 584 | 589 | 594 | 599 | 604 | 609 | 614 | 619 | 624 | 629 | 634 | 639 | 644 | 649 | 654 | 657 | 659 | 663 | 664 | 665 | 666 | 672 | 675 | 680 | 683 | 687 | 691 | 695 | 699 | 703 | 707 | 711 | 715 | 719 | 723 | 727 | 731 | 735 | 739 | 743 | 747 | 751 | 755 | 759 | 763 | 767 | 771 | 775 | 779 | 783 | 787 | 791 | 795 | 799 | 803 | 807 | 811 | 815 | 819 | 823 | 827 | 831 | 835 | 839 | 843 | 847 | 851 | 855 | 859 | 863 | 867 | 871 | 875 | 879 | 883 | 887 | 891 | 895 | 899 | 903 | 907 | 911 | 915 | 919 | 923 | 927 | 931 | 935 | 939 | 943 | 947 | 951 | 955 | 959 | 963 | 967 | 971 | 975 | 979 | 983 | 987 | 991 | 995 | 999 | 1003 | 1007 | 1011 | 1015 | 1019 | 1023 | 1027 | 1031 | 1035 | 1039 | 1043 | 1047 | 1051 | 1055 | 1059 | 1063 | 1067 | 1071 | 1075 | 1079 | 1083 | 1087 | 1091 | 1095 | 1099 | 1103 | 1107 | 1111 | 1115 | 1119 | 1123 | 1127 | 1131 | 1135 | 1139 | 1143 | 1147 | 1151 | 1155 | 1159 | 1163 | 1167 | 1171 | 1175 | 1179 | 1180 | 1185 | 1190 | 1195 | 1200 | 1205 | 1210 | 1215 | 1220 | 1225 | 1230 | 1235 | 1240 | 1245 | 1250 | 1255 | 1260 | 1263 | 1265 | 1269 | 1270 | 1271 | 1272 | --------------------------------------------------------------------------------