Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Novocaine for streaming #99

Open
luciansvnc opened this issue Oct 23, 2014 · 4 comments
Open

Using Novocaine for streaming #99

luciansvnc opened this issue Oct 23, 2014 · 4 comments

Comments

@luciansvnc
Copy link

Hello! I recently tried use Novocaine with Multipeer Connectivity in order to stream music from one device to another. On the 'Host' side I used the following code in order to send data to the output streamer:

[self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
{
[wself.fileReader retrieveFreshAudio:data numFrames:numFrames numChannels:numChannels];
NSLog(@"Time: %f", wself.fileReader.currentTime);

    NSMutableData *theData = [NSMutableData dataWithBytes:data
                                                   length:(numFrames* numChannels*sizeof(float))];

    [wself.outputStream write:(uint8_t *)[theData bytes]  maxLength:[theData length]];
 }];

[self.audioManager play];

On the 'Client' side I tried to receive and read the incoming data using this code:

__weak GuestViewController *wSelf = self;
u_int8_t bytes1[self.audioStreamReadMaxLength];
UInt32 length = [(NSInputStream *)stream read:bytes1 maxLength:self.audioStreamReadMaxLength];

        float *byteData = (float*)malloc(length);
        memcpy(byteData, bytes1 , length);

        self.ringBuffer->AddNewInterleavedFloatData(byteData, 1024, 1);

        if (!self.audioManager.playing) {
            [self.audioManager setOutputBlock:^(float *byteData, UInt32 numFrames, UInt32 numChannels) {
                wSelf.ringBuffer->FetchInterleavedData(byteData, numFrames, numChannels);
            }];
            [self.audioManager play];
        }

When I run the application the sound plays very well on the 'Host' but on the 'Client' side I can only hear some glitches. I spent a couple of days trying to solve this but I really didn't have any luck. Can you please tell me a way to correctly send the data from one device and to receive it and play it on the other one. Thank you very much!

@alexbw
Copy link
Owner

alexbw commented Oct 23, 2014

Sending data over the network is unfortunately not a feature that the
Novocaine project supports. Best of luck!

On Thu, Oct 23, 2014 at 11:15 AM, luciansvnc [email protected]
wrote:

Hello! I recently tried use Novocaine with Multipeer Connectivity in order
to stream music from one device to another. On the 'Host' side I used the
following code in order to send data to the output streamer:

[self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32
numChannels)
{
[wself.fileReader retrieveFreshAudio:data numFrames:numFrames
numChannels:numChannels];
NSLog(@"Time: %f", wself.fileReader.currentTime);

NSMutableData *theData = [NSMutableData dataWithBytes:data
                                               length:(numFrames* numChannels*sizeof(float))];

[wself.outputStream write:(uint8_t *)[theData bytes]  maxLength:[theData length]];

}];

[self.audioManager play];

On the 'Client' side I tried to receive and read the incoming data using
this code:

__weak GuestViewController *wSelf = self;
u_int8_t bytes1[self.audioStreamReadMaxLength];
UInt32 length = [(NSInputStream *)stream read:bytes1
maxLength:self.audioStreamReadMaxLength];

    float *byteData = (float*)malloc(length);
    memcpy(byteData, bytes1 , length);

    self.ringBuffer->AddNewInterleavedFloatData(byteData, 1024, 1);

    if (!self.audioManager.playing) {
        [self.audioManager setOutputBlock:^(float *byteData, UInt32 numFrames, UInt32 numChannels) {
            wSelf.ringBuffer->FetchInterleavedData(byteData, numFrames, numChannels);
        }];
        [self.audioManager play];
    }

When I run the application the sound plays very well on the 'Host' but on
the 'Client' side I can only hear some glitches. I spent a couple of days
trying to solve this but I really didn't have any luck. Can you please tell
me a way to correctly send the data from one device and to receive it and
parse it on the other one. Thank you very much!


Reply to this email directly or view it on GitHub
#99.

@esphynox
Copy link

@luciansvnc
Copy link
Author

@alexbw thank you for your response. @iwxxcz thank you very much for your tip. I will definitely check it out.

@raylenmargono
Copy link

@luciansvnc have you figured out a way for streaming? I'm running into the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants