@lozdanmultimedial wrote:
Hello.
My proyect its now make sound streaming in one pc and received this sound and play it in real time.Pc capture by microphone a sound and encoded in string message :
for( int i = 0; i < bufferSize; i++)
{
message += left[i]+"|";
}
message += "[/p]";and sen it by UDP protocol
That work good.
in the Pc them received this message by apropiate port and decoded in a float array called in my code float left[].
I search examples for playing and all get de samples by a audio file or synthesized sound, not fuond a similar code how i need.
I Gratefully any help.My actually code :
ofApp.h
pragma once
include "ofMain.h"
include "ofxNetwork.h"
class ofApp : public ofBaseApp{
public: void setup(); void update(); void draw(); void conectar(); void recibirMensaje(); void audioOut(float * output, int bufferSize, int nChannels); vector <float> left; ofSoundStream soundStream;// sonido - sound ofxUDPManager miconexion; // net
};
ofApp.cpp
include "ofApp.h"
include "ofxNetwork.h"
define RECONNECT_TIME 200
//--------------------------------------------------------------
void ofApp::setup()
{
conectar();int bufferSize = 256;
left.assign(bufferSize, 0.0);
right.assign(bufferSize, 0.0);
soundStream.setup(this, 0, 2, 44100, bufferSize, 4);
}//--------------------------------------------------------------
void ofApp::update(){}
//--------------------------------------------------------------
void ofApp::draw()
{
recibirMensaje();
}void ofApp::conectar()
{
// we don't want to be running to fast
ofSetVerticalSync(true);
ofSetFrameRate(60);//create the socket and set to send to 127.0.0.1:11999 miconexion.Create(); //miConexion.Connect("127.0.0.1",12000);//--------> miconexion.Bind(11999); // <----------------- miconexion.SetNonBlocking(true);
}
void ofApp::recibirMensaje()// received de message and decoded it
{
char recibido[100000];
miconexion.Receive(recibido,100000);
string msj = recibido;
if(msj !="")
{
vector sonidos = ofSplitString(msj,"[/p]");
vector unSonido;
for( int i = 0; i < sonidos.size(); i++)
{
unSonido = ofSplitString(sonidos[i],"|");left[i] = atof(unSonido[i].c_str()); } }
}
void ofApp::audioOut(float *left, int bufferSize, int nChannels)
{
for( int i = 0; i < bufferSize;i++)
{
output[i] = left[i]; // this is a tautology !!!!!!!!!!
}
}In this code, line 116 the compiler said: error output not declare in thi scope, well I observed taht in the example code audioInputExample the input array its not declared in any place them I think its a system OF array, them output array its not equals ?? or
than anything I 'm forgetting to declared or bad declared or (???) that complier not recognized de system OF output array ??THank full all people
please answre with a code example.
Posts: 1
Participants: 1