[racket] mp3 or ogg play in scheme?

From: synx (plt at synx.us.to)
Date: Sun Oct 3 11:50:45 EDT 2010

On 10/03/2010 06:35 AM, 김태윤 wrote:
> since wav file is too big, is there any way I can play ogg or mp3 file
> in scheme?

That shouldn't be too much trouble. There are many sound playing
libraries and programs that can handle both Vorbis and MP3. I would
recommend you do something like this:

(module file-player racket/base
  (require racket/system)
  (define player (find-executable-path "xmms"))
  (define (play file)
    (system* player (if (path? file) (path->string file) file)))
  (provide play))

Adjust it for your particular ogg and mp3 player of course.

> if there are more useful tip for make a program fun (such as caret
> moving) could you let me know that as well?

Caret moving? You can... do that for your own windows?

(module caret-mover racket/base
  (require racket/gui/base
           racket/class)

  (define frame (new frame% (label "caret mover")
                            (width 300) (height 50)))
  (define text (new text%))
  (define canvas (new editor-canvas% (parent frame) (editor text)))

  (send text insert "Why the heck am I doing this...")

  (send frame show #t)

  (thread
   (λ ()
     (let loop ()
       (send text move-position 'left)
       (sleep/yield 0.5)
       (loop)))))


Posted on the users mailing list.