Andy's LEGO® Mindstorms® Page
About this site
  
What's New?
  
Standard Disclaimer
Quite C
  
Francesco Ferrara
  
Getting Started
  
Installing Quite C
  
Compiling a project
  
Sample Code
Chess
  
The Robot Chess Project
  
Programming Chess
  
First Attempt
  
Version 0
  
Version 1
  
The Program
  
The State of Play
  
The User Interface
  
The Move Generator
  
The Move Applier
  
The Rating Algorithm
  
The Search Algorithm
  
Putting it all together
  
The Robot
  
The Head
  
Moving the head
  
Movies
  
Downloads: Source Executables, MLCad Models
4-in-a-Robot
  
4-in-a-Robot - the Robot
  
The 4-in-a-Robot Base
  
The 4-in-a-Robot Delivery Mechanism
  
The 4-in-a-Robot Controller
  
4-in-a-Robot - the Code
  
The 4-in-a-Robot Algorithm
  
The 4-in-a-Robot Control Programming
  
The 4-in-a-Robot Robot-less version
  
Installing 4-in-a-robot
  
Playing the robotless 4-in-a-robot
  
View the source code
Speech
  
The problems with speech
  
Sounds familiar
  
H8 Timers Background
  
Trial and Error
  
Volume Zapper
  
Actually Speaking
  
Speak.c - the code
  
The VB code generator
Some ideas for the future
  
Room positioning robot
  
Neural Net Bot
  
Pianola
  
Text to speech
LEGO® Mindstorms® Links

[268703]

The VB code generator

  This is pretty simple stuff (hardcoded path etc), but may be useful:
It converts a 8bit unsigned Mono raw sample to C array code.

I use CoolEdit 2000 (http://www.syntrillium.com/) to do the sound recording and conversion. A very cool program and shareware to boot.


Private Sub Form_Load()
Dim ifile As Integer
Dim s As String
Dim b As Byte
Dim l As Long
Dim lLen As Long
Dim sOut As String
ifile = FreeFile
Open "d:\lego\qc\andy\rcx.raw" For Binary As ifile

Do Until EOF(ifile)
Get ifile, , b
'change to 8 sound levels offset from 127
If b >= 128 Then
b = (b - 128) \ 8
Else
b = (127 - b) \ 8
End If
l = l + 1
If l Mod 2 = 1 Then
s = s & "0x" & Hex$(b)
Else
s = s & Hex$(b) & ","
End If

If l = 32 Then
sOut = sOut & s & vbCrLf
s = ""
l = 0
End If
lLen = lLen + 1

Loop
Close ifile

'copy results to clipboard ready to paste
'(dont forget: check the last byte and remove the final comma)
Clipboard.Clear
Clipboard.SetText sOut

MsgBox lLen

End Sub


Back to: Speak.c - the code

Show Topic: Speech