{"id":93,"date":"2026-09-02T20:20:38","date_gmt":"2026-09-02T20:20:38","guid":{"rendered":"https:\/\/robinclapworthy.com\/?p=93"},"modified":"2026-09-02T20:30:28","modified_gmt":"2026-09-02T20:30:28","slug":"barf-finds-his-voice","status":"publish","type":"post","link":"https:\/\/robinclapworthy.com\/?p=93","title":{"rendered":"BARF Finds His Voice"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">One of the things I\u2019m enjoying most about writing Galactic Gladiators in Visual FoxPro is discovering things that make me stop and think:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u201cHang on&#8230; FoxPro can do that?\u201d<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The latest one started with BARF.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">BARF is the alien who appears on screen and communicates with the player. I\u2019d already been playing around with animating his mouth, but obviously if BARF is going to move his mouth, at some point he really ought to say something.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My first thought was the obvious one: record some speech, save it as WAV files and play the appropriate file when required.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But then I discovered something considerably more interesting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Visual FoxPro can talk directly to the Microsoft Speech engine.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because VFP can create and control COM objects, this is remarkably simple. Create the Microsoft speech object, give it some text, and Windows speaks it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Something along the lines of:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>loVoice = CREATEOBJECT(\"SAPI.SpVoice\")\nloVoice.Speak(\"Welcome, Earthling.\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And that&#8217;s basically it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>BARF has a voice.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What I particularly like about this is that BARF&#8217;s dialogue no longer has to be prerecorded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Galactic Gladiators can construct something at runtime and BARF can actually say it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So instead of having a recording saying:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u201cYou have reached level three.\u201d<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">the game could potentially construct:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u201cRob, somehow you have survived level three. Nobody is quite sure how.\u201d<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Or comment on the player&#8217;s score, lives, performance, what just killed them, or anything else the game knows about.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And because it&#8217;s being generated at runtime, I can keep adding ridiculous things for him to say without recording another sound file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s when this stopped being simply <strong>\u201cI&#8217;ve got speech working\u201d<\/strong> and became another one of those moments where the possibilities suddenly opened up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">BARF could interrupt you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">He could mock you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">He could give instructions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">He could react to particularly bad playing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">He could say different things on different playthroughs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">He could even occasionally say something completely unexpected.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All driven by Visual FoxPro.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is something wonderfully inappropriate about a development environment most people associate with database applications controlling a spaceship, animating aliens, playing music, supporting a game controller \u2014 and now talking to the player through Microsoft&#8217;s speech engine.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every time I think I&#8217;ve found Visual FoxPro&#8217;s ceiling, I seem to find another trapdoor in it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And this time an alien called BARF was on the other side.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Unfortunately, now that BARF can talk, the next problem is getting him to shut up.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image_2026-09-02_212014122.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image_2026-09-02_212014122-1024x683.png\" alt=\"\" class=\"wp-image-94\" srcset=\"https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image_2026-09-02_212014122-1024x683.png 1024w, https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image_2026-09-02_212014122-300x200.png 300w, https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image_2026-09-02_212014122-768x512.png 768w, https:\/\/robinclapworthy.com\/wp-content\/uploads\/2026\/09\/image_2026-09-02_212014122.png 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the things I\u2019m enjoying most about writing Galactic Gladiators in Visual FoxPro is discovering things that make me stop and think: \u201cHang on&#8230; FoxPro can do that?\u201d The latest one started with BARF. BARF is the alien who appears on screen and communicates with the player. I\u2019d already been playing around with animating &#8230; <a title=\"BARF Finds His Voice\" class=\"read-more\" href=\"https:\/\/robinclapworthy.com\/?p=93\" aria-label=\"Read more about BARF Finds His Voice\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-93","post","type-post","status-publish","format-standard","hentry","category-galactic-gladiators"],"_links":{"self":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=93"}],"version-history":[{"count":1,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts\/93\/revisions"}],"predecessor-version":[{"id":95,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/posts\/93\/revisions\/95"}],"wp:attachment":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}