diff --git a/client.cpp b/client.cpp deleted file mode 100644 index 3e51bda..0000000 --- a/client.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include "network.h" -#include "syncdataclient.h" -#include "syncdevice.h" - -int main(int argc, char *argv[]) -{ - if (false == initNetwork()) - { - fputs("Failed to init WinSock", stderr); - exit(1); - } - - struct hostent * myhost = gethostbyname("localhost"); - printf("Found IP Address!\n"); - - struct sockaddr_in sain; - sain.sin_family = AF_INET; - sain.sin_port = htons(1338); - sain.sin_addr.s_addr= *( (unsigned long *)(myhost->h_addr_list[0]) ); - SOCKET serverSocket = serverConnect(&sain); - - if (INVALID_SOCKET == serverSocket) - { - puts("connection failed."); - exit(-1); - } - - SyncDataClient syncData(serverSocket); - SyncTrack &track = syncData.getTrack("test"); -// SyncTrack &track2 = syncData.getTrack("test2"); - - puts("recieving..."); - bool done = false; - while (!done) - { -// putchar('.'); - done = syncData.poll(); - } - closesocket(serverSocket); - - closeNetwork(); - - - return 0; -} diff --git a/synceditdata.h b/editor/synceditdata.h similarity index 99% rename from synceditdata.h rename to editor/synceditdata.h index d87774f..c78c83c 100644 --- a/synceditdata.h +++ b/editor/synceditdata.h @@ -1,11 +1,10 @@ #pragma once -#include "sync/data.h" +#include "../sync/network.h" +#include "../sync/data.h" #include #include -#include "network.h" - class SyncEditData : public sync::Data { public: diff --git a/synctracker2.cpp b/editor/synctracker2.cpp similarity index 99% rename from synctracker2.cpp rename to editor/synctracker2.cpp index f468dff..e401817 100644 --- a/synctracker2.cpp +++ b/editor/synctracker2.cpp @@ -1,7 +1,9 @@ // synctracker2.cpp : Defines the entry point for the console application. // -#include "stdafx.h" +#include "../stdafx.h" + +#define WIN32_LEAN_AND_MEAN #include #include @@ -16,7 +18,7 @@ HWND statusBarWin; #define WM_SETROWS (WM_USER+1) #define WM_BIASSELECTION (WM_USER+2) -#include "network.h" +#include "../sync/network.h" static LRESULT CALLBACK setRowsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { diff --git a/trackview.cpp b/editor/trackview.cpp similarity index 99% rename from trackview.cpp rename to editor/trackview.cpp index 393fc77..586758b 100644 --- a/trackview.cpp +++ b/editor/trackview.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "../stdafx.h" #include "trackview.h" #include @@ -112,7 +112,7 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks) sync::Data::TrackContainer::iterator trackIter = syncData->tracks.begin(); for (int track = 0; track <= lastTrack; ++track, ++trackIter) { - ASSERT(trackIter != syncData->tracks.end()); + assert(trackIter != syncData->tracks.end()); if (track < firstTrack) continue; RECT topMargin; @@ -215,7 +215,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks) sync::Data::TrackContainer::iterator trackIter = syncData->tracks.begin(); for (int track = 0; track <= lastTrack; ++track, ++trackIter) { - ASSERT(trackIter != syncData->tracks.end()); + assert(trackIter != syncData->tracks.end()); if (track < firstTrack) continue; for (int row = firstRow; row <= lastRow; ++row) @@ -869,7 +869,7 @@ LRESULT TrackView::onSize(int width, int height) LRESULT TrackView::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - ASSERT(hwnd == this->hwnd); + assert(hwnd == this->hwnd); switch(msg) { @@ -937,7 +937,7 @@ static LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_NCDESTROY: - ASSERT(NULL != trackView); + assert(NULL != trackView); { // call the window proc and store away the return code LRESULT res = trackView->windowProc(hwnd, msg, wParam, lParam); @@ -952,7 +952,7 @@ static LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, break; default: - ASSERT(NULL != trackView); + assert(NULL != trackView); return trackView->windowProc(hwnd, msg, wParam, lParam); } } diff --git a/trackview.h b/editor/trackview.h similarity index 100% rename from trackview.h rename to editor/trackview.h diff --git a/example.cpp b/example.cpp index 4cb2a66..10d9c1e 100644 --- a/example.cpp +++ b/example.cpp @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) if (!syncDevice->update(row)) break; printf("%2.2f: %2.2f \n", row, track.getValue(row)); - Sleep(100); + Sleep(10); } return 0; diff --git a/example_bass.cpp b/example_bass.cpp index efb23c5..abe5406 100644 --- a/example_bass.cpp +++ b/example_bass.cpp @@ -1,11 +1,12 @@ #define WIN32_LEAN_AND_MEAN #include #include +#include #include #include #include #include "sync/device.h" - +#include "bass.h" class BassTimer : public sync::Timer { @@ -20,7 +21,7 @@ public: void play() { BASS_ChannelPlay(stream, false); } float getTime() { return BASS_ChannelBytes2Seconds(stream, BASS_ChannelGetPosition(stream)); } float getRow() { return getTime() * rowRate; } - void setRow(float pos) { BASS_ChannelSetPosition(stream, BASS_ChannelSeconds2Bytes(stream, row / rowRate)); } + void setRow(float row) { BASS_ChannelSetPosition(stream, BASS_ChannelSeconds2Bytes(stream, row / rowRate)); } bool isPlaying() { return (BASS_ChannelIsActive(stream) == BASS_ACTIVE_PLAYING); } private: HSTREAM stream; @@ -38,7 +39,7 @@ int main(int argc, char *argv[]) { // initialize directx IDirect3D9 *d3d = Direct3DCreate9(D3D_SDK_VERSION); - if (NULL == d3d) throw std::exception("update directx, fool."); + if (NULL == d3d) throw std::string("update directx, fool."); // create a window HWND hwnd = CreateWindowEx(0, "static", "BIG", WS_POPUP | WS_VISIBLE, 0, 0, width, height, 0, 0, GetModuleHandle(0), 0); @@ -47,20 +48,20 @@ int main(int argc, char *argv[]) IDirect3DDevice9 *device = NULL; static D3DPRESENT_PARAMETERS present_parameters = {width, height, D3DFMT_X8R8G8B8, 3, D3DMULTISAMPLE_NONE, 0, D3DSWAPEFFECT_DISCARD, 0, WINDOWED, 1, D3DFMT_D24S8, 0, WINDOWED ? 0 : D3DPRESENT_RATE_DEFAULT, 0}; if (D3D_OK != d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device)) - throw std::exception("could not create device. you computer SUCKS!"); + throw std::string("could not create device. you computer SUCKS!"); // init BASS int soundDevice = -1; - if (!BASS_Init(soundDevice, 44100, BASS_DEVICE_LATENCY, 0, 0)) throw FatalException("failed to init bass"); + if (!BASS_Init(soundDevice, 44100, BASS_DEVICE_LATENCY, 0, 0)) throw std::string("failed to init bass"); // load tune - stream = BASS_StreamCreateFile(false, "tune.mp3", 0, 0, BASS_MP3_SETPOS | ((0 == soundDevice) ? BASS_STREAM_DECODE : 0)); - if (NULL == stream) throw std::exception("failed to open tune"); + HSTREAM stream = BASS_StreamCreateFile(false, "tune.mp3", 0, 0, BASS_MP3_SETPOS | ((0 == soundDevice) ? BASS_STREAM_DECODE : 0)); + if (!stream) throw std::string("failed to open tune"); // setup timer and construct sync-device BassTimer timer(stream, 120.0f, 4); std::auto_ptr syncDevice = std::auto_ptr(sync::createDevice("sync", timer)); - if (NULL == syncDevice.get()) throw std::exception("something went wrong - failed to connect to host?"); + if (NULL == syncDevice.get()) throw std::string("something went wrong - failed to connect to host?"); // get tracks sync::Track &clearRTrack = syncDevice->getTrack("clear.r"); diff --git a/stdafx.h b/stdafx.h index 5037286..e18f3a9 100644 --- a/stdafx.h +++ b/stdafx.h @@ -5,6 +5,7 @@ #pragma once +#include #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include diff --git a/sync/device_client.cpp b/sync/device_client.cpp index 561dcb4..2846908 100644 --- a/sync/device_client.cpp +++ b/sync/device_client.cpp @@ -1,6 +1,6 @@ #include "device.h" #include "data.h" -#include "../network.h" +#include "network.h" using namespace sync; diff --git a/network.cpp b/sync/network.cpp similarity index 98% rename from network.cpp rename to sync/network.cpp index 8fb7362..469034b 100644 --- a/network.cpp +++ b/sync/network.cpp @@ -1,3 +1,4 @@ +#include "../stdafx.h" #include "network.h" #include diff --git a/network.h b/sync/network.h similarity index 81% rename from network.h rename to sync/network.h index 99dd3da..1f4e7a6 100644 --- a/network.h +++ b/sync/network.h @@ -2,6 +2,8 @@ #define NETWORK_H #include +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include bool initNetwork(); void closeNetwork(); diff --git a/synctracker2.vcproj b/synctracker2.vcproj index 78a178a..c5c3ed0 100644 --- a/synctracker2.vcproj +++ b/synctracker2.vcproj @@ -184,7 +184,7 @@ > @@ -210,7 +210,15 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + + + - -