cleaning up the structure a bit
This commit is contained in:
parent
02a1ac7e65
commit
4196fc45d8
46
client.cpp
46
client.cpp
@ -1,46 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
||||
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "sync/data.h"
|
||||
#include "../sync/network.h"
|
||||
#include "../sync/data.h"
|
||||
#include <stack>
|
||||
#include <list>
|
||||
|
||||
#include "network.h"
|
||||
|
||||
class SyncEditData : public sync::Data
|
||||
{
|
||||
public:
|
||||
@ -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 <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
@ -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)
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include "trackview.h"
|
||||
#include <vector>
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include <memory>
|
||||
#include <exception>
|
||||
#include <cstdio>
|
||||
#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<sync::Device> syncDevice = std::auto_ptr<sync::Device>(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");
|
||||
|
||||
1
stdafx.h
1
stdafx.h
@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <winsock2.h>
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "device.h"
|
||||
#include "data.h"
|
||||
#include "../network.h"
|
||||
#include "network.h"
|
||||
|
||||
using namespace sync;
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "../stdafx.h"
|
||||
#include "network.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
#define NETWORK_H
|
||||
|
||||
#include <winsock2.h>
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
|
||||
bool initNetwork();
|
||||
void closeNetwork();
|
||||
@ -184,7 +184,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\network.cpp"
|
||||
RelativePath=".\sync\network.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -192,7 +192,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\synctracker2.cpp"
|
||||
RelativePath=".\editor\synctracker2.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -200,7 +200,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\trackview.cpp"
|
||||
RelativePath=".\editor\trackview.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@ -210,7 +210,15 @@
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\network.h"
|
||||
RelativePath=".\sync\data.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sync\device.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sync\network.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -222,11 +230,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\synceditdata.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\trackview.h"
|
||||
RelativePath=".\sync\track.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user