-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished moving osc to it's own class
- Loading branch information
1 parent
1052591
commit 12dcaea
Showing
4 changed files
with
63 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,42 @@ | ||
#include "osc_message.h" | ||
|
||
osc_message::osc_message(std::string address, char type) | ||
osc_message::osc_message(char* address, char type) | ||
{ | ||
|
||
int len = strlen(address)+1; | ||
writerIndex = quantize(len, 4); | ||
memcpy(message, address, writerIndex); | ||
|
||
message[writerIndex++] = ','; | ||
message[writerIndex++] = type; | ||
message[writerIndex++] = '\0'; | ||
message[writerIndex++] = '\0'; | ||
} | ||
|
||
osc_message::osc_message(char* data, int size) | ||
{ | ||
|
||
} | ||
|
||
osc_float_message::osc_float_message(std::string address, float value): osc_message(address, 'f') | ||
osc_float_message::osc_float_message(char* address, float value): osc_message(address, 'f') | ||
{ | ||
|
||
char* bytes = static_cast<char*>(static_cast<void*>(&value)); | ||
swap_endianness(bytes, sizeof value); | ||
memcpy(&message[writerIndex], bytes, sizeof value); | ||
writerIndex += sizeof value; | ||
} | ||
|
||
osc_string_message::osc_string_message(std::string address, std::string value) : osc_message(address, 's') | ||
osc_string_message::osc_string_message(char* address, char* value) : osc_message(address, 's') | ||
{ | ||
|
||
int len = strlen(value)+1; | ||
int quantizedLength = quantize(len, 4); | ||
memcpy(&message[writerIndex], value, quantizedLength); | ||
writerIndex += quantizedLength; | ||
} | ||
|
||
|
||
osc_int_message::osc_int_message(char* address, int value) : osc_message(address, 'i') { | ||
char* bytes = static_cast<char*>(static_cast<void*>(&value)); | ||
swap_endianness(bytes, sizeof value); | ||
memcpy(&message[writerIndex], bytes, sizeof value); | ||
writerIndex += sizeof value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters