将void *内容复制到SigLib结构中SLData_t * [英] Copy void* content into SigLib struct SLData_t*

查看:84
本文介绍了将void *内容复制到SigLib结构中SLData_t *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C ++做一个Windows应用程序。我有下一个花花公子。

I am doing an Windows application using C++. I have the next dude.

我有这个函数,我收到一个 void * / p>

I have this function where I receive a void * with data audio capture:

void Pre_proc_mono::PreProcess(void *data, int lenbytes) {
    SLData_t *signal1;
    SLData_t *signal2;
    SLData_t *result;
    signal1 = (SLData_t*)data;
    signal2 = new SLData_t[lenbytes];
    result = new SLData_t[2 * lenbytes - 1];

    for (int i = 0; i < lenbytes; i++){
        signal2[i] = signal1[i];
    }
}

循环总是在11000左右失败,为什么?我做错了什么?然后,该想法与SigLib库(DSP库)进行相关交叉。所以我需要有数组的限制,而不是指针,所以我这样做。帮助?

The loop always fail around 11000, why? What am I doing wrong ? The idea is then do a correlation cross with SigLib library (DSP library). So I need have arrays with limit, not pointers so I am doing this instead. Help?

编辑:
首先,当我说失败时,我想说当循环达到大约11000时出现和运行时错误。
第二个SLData_t是SigLib库的一种日期,做相关交叉的函数需要这个变量作为输入。

First, when I said fails I want to say that when loop reaches to around 11000 appears and runtime error. Second SLData_t is a kind of date of the SigLib library, and the function to doing correlation cross need this variable as input.

推荐答案

以下可能有助于:

void Pre_proc_mono::PreProcess(void *data, int lenbytes) {
    SLData_t* signal1 = reinterpret_cast<SLData_t*>(data);
    const std::size_t signalCount = lenbytes / sizeof (SLData_t);
    // then if you want to copy inside a std::vector
    std::vector<SLData_t> signal2(signal1, signal1 + signalCount);
}

这篇关于将void *内容复制到SigLib结构中SLData_t *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆