public Wave_Node[] analize(string s) { List <string> frames = get_frams(); Wave_Node[] result = new Wave_Node[frames.Count()]; int i = 0; foreach (string frame in frames) { result[i] = frame_to_wave(frame); i++; } return(result); }
public Wave_Node frame_to_wave(string s) { int offset = 1; int frame_length = s[0]; //数据的字节长度,不包括CRC和帧头 int data_num = frame_length / 4; //数字的个数,一个4字节 if (frame_length % 4 != 0) { throw new Exception("no enough"); } Wave_Node result = new Wave_Node(); byte[] bytes = System.Text.Encoding.Default.GetBytes(s); float[] datas = new float[data_num]; for (int i = 0; i < data_num; ++i) { float data = BitConverter.ToSingle(bytes, offset + i * 4); result.add(data); } return(result); }