免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 1491 | 回复: 15
打印 上一主题 下一主题

HELLP!!! PLEASE!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-03-04 13:03 |只看该作者 |倒序浏览
MSG_Body julius_MsgBody;

char *mstart;
int mlen;

/* declare the static variables*/
static void *p_body = NULL;
static boolean wav_bp = FALSE;
static int maxlenb, nowlen;
static SP16 bpre_data[2];
static boolean bhas_pre = FALSE;  

static int sfreq;

int  mybufread(void *ptr, size_t size, size_t n)
{
   int cnt=0,i=0;
   char *t1,*t2;
   
   t1 = (char*)ptr;
   t2 = (char*)p_body;
   if(NULL == t2)
   {
       return -2;
   }
   
   for(i=0;i<(size*n);i++)
   {
     *t1 = *t2;
     t1 = t1 +1;
     t2 = t2 +1;
     if(t2 == mstart + mlen)
     {
         break;
     }
   }
   cnt = i;
   if(i<=0)
   {
     cnt = -2;/* read error */
   }
   if(i<(size*n-1) && i>;0)
   {
     cnt = -1;/* end of buffer */
   }
   if(cnt>;0)
   {
     (char*)p_body = (char*)p_body + cnt;
   }
  
   return(cnt);
}


int adin_buffer_read(SP16 *buf, int sampnum)
{
  int cnt;
  if (wav_bp)
  {
    cnt = mybufread(&(buf[0]), sizeof(SP16), sampnum);
    if (nowlen + cnt >; maxlenb)
    {
      cnt = maxlenb - nowlen;
    }
  }
  else
  {
    if (bhas_pre)
    {
      buf[0] = bpre_data[0];
      buf[1] = bpre_data[1];
      bhas_pre = FALSE;
      
      cnt = mybufread(&(buf[2]), sizeof(SP16), sampnum - 2);
      if (cnt >; 0) cnt += 2;
    }
    else
    {
      cnt = mybufread(&buf, sizeof(SP16), sampnum);
    }
  }
  if (cnt <= 0)
  {                /* error or EOF */
    return cnt;        /* -1 ,EOF ; -2, error*/
  }
  /* all .wav data are in little endian */
  /* assume .raw data are in big endian */
#ifdef WORDS_BIGENDIAN
  if (wav_bp) swap_sample_bytes(buf, cnt);
#else
  if (!wav_bp) swap_sample_bytes(buf, cnt);
#endif
  return cnt;
   
}


I use it like this  :  cnt = adin_buffer_read(&(buffer[bp]), bpmax - bp);

论坛徽章:
0
2 [报告]
发表于 2004-03-04 13:07 |只看该作者

HELLP!!! PLEASE!!!

这个程序总是不能正确的将数据读取道buffer中。
是因为我的参数引用方式不对吗?要崩溃了。弄了4天也弄不明白。

论坛徽章:
0
3 [报告]
发表于 2004-03-04 13:08 |只看该作者

HELLP!!! PLEASE!!!

大家能帮忙看看么,先感谢各位了  :)

论坛徽章:
0
4 [报告]
发表于 2004-03-04 13:16 |只看该作者

HELLP!!! PLEASE!!!

晕,把代码整理一下吧

论坛徽章:
0
5 [报告]
发表于 2004-03-04 13:22 |只看该作者

HELLP!!! PLEASE!!!

晕,刚刚才注意代码那么乱。
我直接从qt中拷贝出来的,怎么格式都乱了。

论坛徽章:
0
6 [报告]
发表于 2004-03-04 13:26 |只看该作者

HELLP!!! PLEASE!!!

MSG_Body julius_MsgBody;

char *mstart;
int mlen;

/* declare the static variables*/
static void *p_body = NULL;
static boolean wav_bp = FALSE;
static int maxlenb, nowlen;
static SP16 bpre_data[2];
static boolean bhas_pre = FALSE;

static int sfreq;

int mybufread(void *ptr, size_t size, size_t n)
{
        int cnt=0,i=0;
        char *t1,*t2;
       
        t1 = (char*)ptr;
        t2 = (char*)p_body;
        if(NULL == t2)
        {
                return -2;
        }
       
        for(i=0;i<(size*n);i++)
        {
                *t1 = *t2;
                t1 = t1 +1;
                t2 = t2 +1;
                if(t2 == mstart + mlen)
                {
                        break;
                }
        }
        cnt = i;
        if(i<=0)
        {
                cnt = -2;/* read error */
        }
        if(i<(size*n-1) && i>;0)
        {
                cnt = -1;/* end of buffer */
        }
        if(cnt>;0)
        {
                (char*)p_body = (char*)p_body + cnt;
        }
       
        return(cnt);
}


int adin_buffer_read(SP16 *buf, int sampnum)
{
        int cnt;
        if (wav_bp)
        {
                cnt = mybufread(&(buf[0]), sizeof(SP16), sampnum);
                if (nowlen + cnt >; maxlenb)
                {
                        cnt = maxlenb - nowlen;
                }
        }
        else
        {
                if (bhas_pre)
                {
                        buf[0] = bpre_data[0];
                        buf[1] = bpre_data[1];
                        bhas_pre = FALSE;
                       
                        cnt = mybufread(&(buf[2]), sizeof(SP16), sampnum - 2);
                        if (cnt >; 0) cnt += 2;
                }
                else
                {
                        cnt = mybufread(&buf, sizeof(SP16), sampnum);
                }
        }
        if (cnt <= 0)
        { /* error or EOF */
                return cnt; /* -1 ,EOF ; -2, error*/
        }
        /* all .wav data are in little endian */
        /* assume .raw data are in big endian */
#ifdef WORDS_BIGENDIAN
        if (wav_bp) swap_sample_bytes(buf, cnt);
#else
        if (!wav_bp) swap_sample_bytes(buf, cnt);
#endif
        return cnt;
       
}


I use it like this : cnt = adin_buffer_read(&(buffer[bp]), bpmax - bp);
[/quote]

论坛徽章:
0
7 [报告]
发表于 2004-03-04 13:27 |只看该作者

HELLP!!! PLEASE!!!

晕,还是这样,怎么回事情,从VC中拷贝,也是这样啊

论坛徽章:
0
8 [报告]
发表于 2004-03-04 13:30 |只看该作者

HELLP!!! PLEASE!!!

大家帮忙看看,我别了个文件上来,希望不会乱

aaaaaaaaaaaaaaaa.JPG

1.69 KB, 下载次数: 3

论坛徽章:
0
9 [报告]
发表于 2004-03-04 13:30 |只看该作者

HELLP!!! PLEASE!!!

晕,不玩了。只好自己看了

论坛徽章:
0
10 [报告]
发表于 2004-03-04 13:50 |只看该作者

HELLP!!! PLEASE!!!

你用code
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP