|
2007/9/28(Fri) 19:48:54|NO.11247
早速教えていただいたプラグインでプログラムを組んでみたのですが、どうもうまくいきません。
下のプログラムを実行すると録音の部分がうまくいかないみたいなのですがよくわかりません。どのように直したらよいのですか?
#include "hspsock.as"
#include "hspwave.as"
screen 0,400,300
onexit *owari
title "音声通信"
port=14325 ;使用するポート
comment=""
ip=""
roc=40000
sdim buf1,roc
sdim buf2,roc
cls 1
pos 150,50 : button "ホスト",*host
pos 150,150 : button "クライアント",*client
input ip,150,25
stop
;ホストの処理
*host
cls 1
sockmake 0,port ;ホストを立てる
if stat!0 : goto *tusinerr
mes "通信待機中...."
ipget ;自分のIP取得
if stat!0:mes "エラー"
mes refstr
repeat -1
wait 1
sockwait 0 ;接続を待つ
if stat>=2 : goto *tusinerr
if stat=0 : goto *main
loop
;クライアントの処理
*client
sockopen 0,ip,port ;ソケットを初期化し繋げる
if stat!0 : goto *tusinerr
goto *main
w_in_open 22050,8,1 ;録音のためのデバイスを開く
w_out_open 22050,8 ;再生のためのデバイスを開く
;メイン画面
*main
w_in_add buf1,roc,1 ;録音用のバッファを追加(最大8)
if stat!0 :dialog "録音エラー" :goto *tusinerr
gosub *sousin
wait 1
sockcheck 0 ;受信できるデータが届いているか確認
if stat>=2 : goto *tusinerr
if stat=0 :gosub *zyusin
w_out_add buf2,roc ;再生用のバッファを追加(最大8)
if stat!0 :dialog "再生エラー" :goto *tusinerr
goto *main
*zyusin ;受信の処理
sockgetb buf2,b,roc ;データ受信
if stat=0 : goto *tusinerr
return
;送信するときの処理
*sousin
sockputb buf1 ;メッセージの送信
if stat=0 : goto *tusinerr
return
*tusinerr
dialog "通信中にエラーが発生しました。"
*owari
sockclose 0 ;ソケット切断
end
![](../images/bbs/mark_main_g.gif)
| |