Permalink
Browse files

moved to github

  • Loading branch information...
0 parents commit d8a7ed86ad4c18afcb26e5487c01524374d24757 @emarschner committed Dec 20, 2011
Showing with 23,397 additions and 0 deletions.
  1. +56 −0 Color.cpp
  2. +178 −0 Engine.cpp
  3. +118 −0 MyAudio.cpp
  4. +692 −0 Network.cpp
  5. +1 −0 Point.cpp
  6. +275 −0 Shape.cpp
  7. +1,416 −0 Widget.cpp
  8. +24 −0 include/Color.h
  9. +22 −0 include/Common.h
  10. +55 −0 include/Engine.h
  11. +40 −0 include/MyAudio.h
  12. +119 −0 include/Network.h
  13. +51 −0 include/Point.h
  14. +117 −0 include/Shape.h
  15. +395 −0 include/Widget.h
  16. +81 −0 ip/IpEndpointName.cpp
  17. +84 −0 ip/IpEndpointName.h
  18. +49 −0 ip/NetworkingUtils.h
  19. +43 −0 ip/PacketListener.h
  20. +40 −0 ip/TimerListener.h
  21. +158 −0 ip/UdpSocket.h
  22. +57 −0 ip/posix/NetworkingUtils.cpp
  23. +546 −0 ip/posix/UdpSocket.cpp
  24. +88 −0 ip/win32/NetworkingUtils.cpp
  25. +521 −0 ip/win32/UdpSocket.cpp
  26. +496 −0 main.cpp
  27. +68 −0 makefile
  28. +73 −0 osc/MessageMappingOscPacketListener.h
  29. +54 −0 osc/OscException.h
  30. +69 −0 osc/OscHostEndianness.h
  31. +639 −0 osc/OscOutboundPacketStream.cpp
  32. +142 −0 osc/OscOutboundPacketStream.h
  33. +72 −0 osc/OscPacketListener.h
  34. +241 −0 osc/OscPrintReceivedElements.cpp
  35. +49 −0 osc/OscPrintReceivedElements.h
  36. +722 −0 osc/OscReceivedElements.cpp
  37. +486 −0 osc/OscReceivedElements.h
  38. +40 −0 osc/OscTypes.cpp
  39. +178 −0 osc/OscTypes.h
  40. +178 −0 stk/ADSR.h
  41. +146 −0 stk/Asymp.h
  42. +153 −0 stk/BandedWG.h
  43. +127 −0 stk/BeeThree.h
  44. +186 −0 stk/BiQuad.h
  45. +151 −0 stk/Blit.h
  46. +148 −0 stk/BlitSaw.h
  47. +170 −0 stk/BlitSquare.h
  48. +144 −0 stk/BlowBotl.h
  49. +185 −0 stk/BlowHole.h
  50. +150 −0 stk/BowTable.h
  51. +157 −0 stk/Bowed.h
  52. +147 −0 stk/Brass.h
  53. +172 −0 stk/Chorus.h
  54. +152 −0 stk/Clarinet.h
  55. +138 −0 stk/Cubic.h
  56. +188 −0 stk/Delay.h
  57. +207 −0 stk/DelayA.h
  58. +203 −0 stk/DelayL.h
  59. +130 −0 stk/Drummer.h
  60. +120 −0 stk/Echo.h
  61. +79 −0 stk/Effect.h
  62. +130 −0 stk/Envelope.h
  63. +122 −0 stk/FM.h
  64. +135 −0 stk/FMVoices.h
  65. +164 −0 stk/FileLoop.h
  66. +141 −0 stk/FileRead.h
  67. +116 −0 stk/FileWrite.h
  68. +196 −0 stk/FileWvIn.h
  69. +102 −0 stk/FileWvOut.h
  70. +124 −0 stk/Filter.h
  71. +155 −0 stk/Fir.h
  72. +166 −0 stk/Flute.h
  73. +190 −0 stk/FormSwep.h
  74. +41 −0 stk/Function.h
  75. +50 −0 stk/Generator.h
  76. +209 −0 stk/Granulate.h
  77. +126 −0 stk/HevyMetl.h
  78. +202 −0 stk/Iir.h
  79. +157 −0 stk/InetWvIn.h
  80. +98 −0 stk/InetWvOut.h
  81. +102 −0 stk/Instrmnt.h
  82. +166 −0 stk/JCRev.h
  83. +112 −0 stk/JetTable.h
  84. +143 −0 stk/Mandolin.h
  85. +144 −0 stk/Mesh2D.h
  86. +166 −0 stk/Messager.h
  87. +135 −0 stk/MidiFileIn.h
  88. +154 −0 stk/Modal.h
  89. +65 −0 stk/ModalBar.h
  90. +108 −0 stk/Modulate.h
  91. +125 −0 stk/Moog.h
  92. +74 −0 stk/Mutex.h
  93. +160 −0 stk/NRev.h
  94. +83 −0 stk/Noise.h
  95. +134 −0 stk/OnePole.h
  96. +134 −0 stk/OneZero.h
  97. +140 −0 stk/PRCRev.h
  98. +127 −0 stk/PercFlut.h
  99. +55 −0 stk/Phonemes.h
  100. +107 −0 stk/PitShift.h
  101. +117 −0 stk/Plucked.h
  102. +113 −0 stk/PoleZero.h
  103. +143 −0 stk/ReedTable.h
  104. +127 −0 stk/Resonate.h
  105. +128 −0 stk/Rhodey.h
  106. +980 −0 stk/RtAudio.h
  107. +60 −0 stk/RtError.h
  108. +306 −0 stk/RtMidi.h
  109. +125 −0 stk/RtWvIn.h
  110. +96 −0 stk/RtWvOut.h
  111. +129 −0 stk/SKINI.msg
  112. +135 −0 stk/SKINI.tbl
  113. +78 −0 stk/Sampler.h
  114. +166 −0 stk/Saxofony.h
  115. +168 −0 stk/Shakers.h
  116. +129 −0 stk/Simple.h
  117. +159 −0 stk/SineWave.h
  118. +136 −0 stk/SingWave.h
  119. +129 −0 stk/Sitar.h
  120. +122 −0 stk/Skini.h
  121. +89 −0 stk/Socket.h
  122. +79 −0 stk/Sphere.h
  123. +154 −0 stk/StifKarp.h
  124. +545 −0 stk/Stk.h
  125. +216 −0 stk/TapDelay.h
  126. +65 −0 stk/TcpClient.h
  127. +65 −0 stk/TcpServer.h
  128. +98 −0 stk/Thread.h
  129. +125 −0 stk/TubeBell.h
  130. +158 −0 stk/Twang.h
  131. +153 −0 stk/TwoPole.h
  132. +149 −0 stk/TwoZero.h
  133. +76 −0 stk/UdpSocket.h
  134. +68 −0 stk/Vector3D.h
  135. +161 −0 stk/VoicForm.h
  136. +219 −0 stk/Voicer.h
  137. +128 −0 stk/Whistle.h
  138. +128 −0 stk/Wurley.h
  139. +46 −0 stk/WvIn.h
  140. +85 −0 stk/WvOut.h
@@ -0,0 +1,56 @@
+#include <stdlib.h>
+#include <time.h>
+
+#include "Color.h"
+
+Color Color::operator+(Color color)
+{
+ Color c;
+ c.r = color.r + this->r;
+ c.g = color.g + this->g;
+ c.b = color.b + this->b;
+ c.a = color.a + this->a;
+
+ return c;
+}
+
+Color Color::operator-(Color color)
+{
+ Color c;
+ c.r = this->r - color.r;
+ c.g = this->g - color.g;
+ c.b = this->b - color.b;
+ c.a = this->a - color.a;
+
+ return c;
+}
+
+Color Color::operator*(float num)
+{
+ Color c;
+ c.r = this->r * num;
+ c.g = this->g * num;
+ c.b = this->b * num;
+ c.a = this->a * num;
+
+ return c;
+}
+
+Color Color::operator/(float num)
+{
+ Color c;
+ c.r = this->r / num;
+ c.g = this->g / num;
+ c.b = this->b / num;
+ c.a = this->a / num;
+
+ return c;
+}
+
+Color Color::generateRandomColor()
+{
+ Color c((float)(rand() % 100) / 100,
+ (float)(rand() % 100) / 100,
+ (float)(rand() % 100) / 100);
+ return c;
+}
@@ -0,0 +1,178 @@
+#include <iostream>
+#include <stdlib.h>
+
+#ifdef __MACOSX_CORE__
+#include <GLUT/glut.h>
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <GL/glut.h>
+#endif
+
+#include "Engine.h"
+#include "Network.h"
+
+Engine::Engine() :
+ m_selectedWidget(NULL),
+ m_newRoundPad(NULL),
+ m_mouseCursor(new Spiral(Point2D(0, 0), 360, 5, 0, 5)),
+ m_cursorText(new Text(Point2D(-100, 100), "")),
+ m_textMode(TEXT_REPLACE),
+ m_xLine(Point2D(0, 0), Point2D(0, 0)),
+ m_yLine(Point2D(0, 0), Point2D(0, 0))
+{
+ m_mouseCursor->setColor(Color(51 / (float)255, 153 / (float)255, 1, 1));
+ m_mouseCursor->setFilled(true);
+ m_cursorText->setColor(Color(51 / (float)255, 153 / (float)255, 1, 1));
+ m_xLine.setColor(Color(0.95, 0.95, 0.95, 0.5));
+ m_xLine.setLineWidth(0.1);
+ m_yLine.setColor(Color(0.95, 0.95, 0.95, 0.5));
+ m_yLine.setLineWidth(0.1);
+ m_parent = this;
+}
+
+Engine::~Engine()
+{
+ delete m_mouseCursor;
+ delete m_cursorText;
+}
+
+bool Engine::handleDraw(float x, float y)
+{
+ m_maxRadius = FLT_MAX;
+ for (std::vector<Widget*>::iterator cit = m_children.begin(); cit != m_children.end(); cit++) {
+ RoundPad* pad = dynamic_cast<RoundPad*>(*cit);
+ if (pad)
+ m_maxRadius = std::min(m_maxRadius,
+ Point2D::distance(m_mouseDownPos,
+ pad->getCenter()) - pad->getRadius());
+ }
+
+ if (m_newRoundPad)
+ m_newRoundPad->setRadius(std::min(m_maxRadius,
+ Point2D::distance(m_newRoundPad->getCenter(),
+ Point2D(x, y))));
+ else
+ m_newRoundPad = new RoundPad(m_mouseDownPos, std::min(m_maxRadius,
+ Point2D::distance(m_mouseDownPos,
+ Point2D(x, y))));
+ return true;
+}
+
+bool Engine::handleDrawEnd(float x, float y)
+{
+ if (m_newRoundPad) {
+ Widget::getAll()->insert(WidgetData(m_newRoundPad->getUuid(), m_newRoundPad));
+ this->addChild(m_newRoundPad);
+ s_network->sendObjectMessage(m_newRoundPad);
+ m_newRoundPad = NULL;
+ }
+ return true;
+}
+
+bool Engine::onKeyDown(unsigned char key, float x, float y)
+{
+ switch(key) {
+ case 127:
+ if (m_textMode == TEXT_REPLACE && m_selectedWidget &&
+ (m_selectedWidget = m_selectedWidget->getParent()->removeChild(m_selectedWidget))) {
+ for (int i = 0; i < 5; i++)
+ s_network->sendObjectMessage(m_selectedWidget, true);
+ delete m_selectedWidget;
+ m_selectedWidget = NULL;
+ } else if (m_textMode == TEXT_APPEND) {
+ std::string text;
+ if (m_selectedWidget && dynamic_cast<RoundPad*>(m_selectedWidget)) {
+ RoundPad* pad = (RoundPad*)m_selectedWidget;
+ text = pad->getCommentText()->getText();
+ pad->setCommentText(text.substr(0, text.length() - 1));
+ s_network->sendRoundPadTextMessage(pad);
+ } else {
+ text = m_cursorText->getText();
+ m_cursorText->setText(text.substr(0, text.length() - 1));
+ s_network->sendPeerTextMessage(m_cursorText->getText());
+ }
+ }
+ break;
+ case 27:
+ exit(1);
+ break;
+ default:
+ std::string character(1, key);
+ if (m_selectedWidget && dynamic_cast<RoundPad*>(m_selectedWidget)) {
+ RoundPad* pad = (RoundPad*)m_selectedWidget;
+ if (m_textMode == TEXT_REPLACE) {
+ pad->setCommentText(character);
+ m_textMode = TEXT_APPEND;
+ } else
+ pad->appendCommentText(character);
+ s_network->sendRoundPadTextMessage(pad);
+ } else {
+ if (m_textMode == TEXT_REPLACE) {
+ m_cursorText->setText(character);
+ m_textMode = TEXT_APPEND;
+ } else
+ m_cursorText->setText(m_cursorText->getText() + character);
+ s_network->sendPeerTextMessage(m_cursorText->getText());
+ }
+ }
+
+ glutPostRedisplay( );
+ return true;
+}
+
+void Engine::draw()
+{
+ // clear the color and depth buffers
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ // Draw the elements
+ for (int i = 0; i < m_children.size(); i ++)
+ m_children[i]->draw();
+
+ // Draw in-progress new round pad, if any
+ if (m_newRoundPad)
+ m_newRoundPad->draw();
+
+ Network::PeerMap* peers = s_network->getPeers();
+ for (Network::PeerMap::iterator pit = peers->begin(); pit != peers->end(); pit++)
+ pit->second->draw();
+
+ m_xLine.draw();
+ m_yLine.draw();
+ m_mouseCursor->draw();
+ m_cursorText->draw();
+}
+
+void Engine::setMouseCursorPosition(float x, float y)
+{
+ m_mouseCursor->setCenter(Point2D(x, y));
+ m_cursorText->setPos(Point2D(x + 10, y + 5));
+
+ for (std::vector<Widget *>::iterator cit = m_children.begin(); cit != m_children.end(); cit++)
+ if ((*cit)->hitTest(x, y)) {
+ m_xLine.setPoints(Point2D(0, 0), Point2D(0, 0));
+ m_yLine.setPoints(Point2D(0, 0), Point2D(0, 0));
+ return;
+ }
+
+ m_xLine.setPoints(Point2D(0, y), Point2D(m_width, y));
+ m_yLine.setPoints(Point2D(x, 0), Point2D(x, m_height));
+ return;
+}
+
+void Engine::setSize(int w, int h)
+{
+ m_width = w;
+ m_height = h;
+}
+
+void Engine::setCursorText(std::string text)
+{
+ m_cursorText->setText(text);
+}
@@ -0,0 +1,118 @@
+//
+// MyAudio.cpp
+// stkExample
+//
+// Created by Jorge Herrera on 2011-10-26.
+//
+// ------------------
+// Class to abstract audio stream
+// IMPORTANT: it will quit the app if it can't setup or start!!!
+
+
+#include "MyAudio.h"
+#include <iostream>
+#include <cstdlib>
+
+// constructor
+MyAudio::MyAudio( unsigned int nChann, float sr, unsigned int buffSize, RtAudioFormat format )
+{
+ m_audio = NULL;
+ m_numChannels = nChann;
+ m_sampleRate = sr;
+ m_bufferSize = buffSize;
+ m_format = format;
+}
+
+// destructor
+MyAudio::~MyAudio()
+{
+ if( m_audio )
+ {
+ stop();
+ delete m_audio;
+ }
+}
+
+// RtAudio configuration
+void MyAudio::setup( RtAudioCallback callback, void * userData )
+{
+ if( !callback )
+ {
+ std::cerr << "No callback provided!" << std::endl;
+ exit(1);
+ }
+
+ try
+ {
+ m_audio = new RtAudio();
+ }
+ catch( RtError & err ) {
+ err.printMessage();
+ exit(1);
+ }
+
+ if( m_audio->getDeviceCount() < 1 )
+ {
+ // nopes
+ std::cout << "no audio devices found!" << std::endl;
+ exit(1);
+ }
+
+ // let RtAudio print messages to stderr.
+ m_audio->showWarnings( true );
+
+ // set input and output parameters
+ RtAudio::StreamParameters iParams, oParams;
+ iParams.deviceId = m_audio->getDefaultInputDevice();
+ iParams.nChannels = m_numChannels;
+ iParams.firstChannel = 0;
+ oParams.deviceId = m_audio->getDefaultOutputDevice();
+ oParams.nChannels = m_numChannels;
+ oParams.firstChannel = 0;
+
+ // set the callback and start stream
+ try
+ {
+ m_audio->openStream( &oParams,
+ &iParams,
+ m_format,
+ m_sampleRate,
+ &m_bufferSize,
+ callback,
+ userData);
+
+ std::cerr << "Buffer size defined by RtAudio: " << m_bufferSize << std::endl;
+ }
+ catch( RtError & err )
+ {
+ err.printMessage();
+ exit(1);
+ }
+
+}
+
+// start audio stream
+void MyAudio::start()
+{
+ try
+ {
+ m_audio->startStream();
+ // test RtAudio functionality for reporting latency.
+ std::cout << "stream latency: " << m_audio->getStreamLatency() << " frames" << std::endl;
+ }
+ catch( RtError & err )
+ {
+ err.printMessage();
+ exit(1);
+ }
+}
+
+// stop audio stream
+void MyAudio::stop()
+{
+ if( m_audio )
+ {
+ if ( m_audio->isStreamRunning() ) m_audio->stopStream();
+ if ( m_audio->isStreamOpen() ) m_audio->closeStream();
+ }
+}
Oops, something went wrong.

0 comments on commit d8a7ed8

Please sign in to comment.