I want to play music in Lispbuilder-sdl, but I can't do it because of the error "BABEL-ENCODINGS: INVALID-UTF8-STARTER-BYTE".

Asked 2 years ago, Updated 2 years ago, 108 views

Currently, we are making the game by referring to the PDF below.
http://www.usamimi.info/~ide/program/stg_doc/stg-commonlisp.pdf

The above PDF states that I should look into and implement the sound by myself, so I tried to run lispbuilder-sdl-mixer-examples to see how it works, but the following error occurred and it didn't work.

$sbcl --load mixer.lisp
This is SBCL 1.3.10, implementation of ANSI Common Lisp.
More information about SBCL is available at http://www.sbcl.org/.

長く Because it will be longer, we will omit the parts that appear even under normal conditions.
~~Omitted~~
* Some quicklisp logs are also omitted.
Toload "cffi":
Toload "alexandria":
Toload "babel":
Toload "cl-autowrap":
Toload "cl-ppcre":
Toload "trivial-garbage":
Toload "cl-opengl":
Toload "lispbuilder-sdl":
Toload "lispbuilder-sdl-mixer":
Toload "lispbuilder-sdl-mixer-examples":

While evaluating the form starting at line 43, column0
of#P "C:/cygwin64/home/■■■■■/work/SDL/mixer.lisp":

debugger invoked on a BABEL-ENCODINGS:INVALID-UTF8-STARTER-BYTE in thread

Illegal:UTF-8 character starting at position 26.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invocable by number or by positively-abbreviated name):
0—[RETRY] Retry EVAL of current toplevel form.
1:[CONTINUE] Ignore error and continue loading file > "C:\cygwin64\home\■■■■■\work\SDL\mixer.lisp".
2:[ABORT] Abort loading file > "C:\cygwin64\home\■■■■\work\SDL\mixer.lisp".
3: Ignore runtime option --load "mixer.lisp".
4:Skip rest of --eval and --load options.
5:Skip to toplevel READ/EVAL/PRINT loop.
6:[EXIT] Exit SBCL (calling#'EXIT, killing the process).

((LABELS BABEL-ENCODINGS::UTF-8-DECODER:IN>"C:/cygwin64/home/■■■■■/work/SDL/./quicklisp/dist/quicklisp/software/cffi_0.>17.1/src/string.lisp")#)

The code is as follows:

mixer.lisp

;setting encode        
(setfsb-impl::* default-external-format*:utf-8)
(setfsb-alien::* default-c-string-external-format*:utf-8)

; quicklisp initialize
(let((quicklisp-init"./quicklisp/setup.lisp"))
    (when (probe-file quicklisp-init)
        (load quicklisp-init))

(ql:quickload:cffi)
(mapcar#'(lambda(path) 
            (pushnew path cffi: *foreign-library-directories*)
                              :test#'equal))
        '(."/FrameWorks/")
(ql:quickload:alexandria)
(ql:quickload:babel)
(ql:quickload:cl-autowrap)
(ql:quickload:cl-ppcre)
(ql:quickload:trivial-garbage)
(ql:quickload:cl-opengl)
(ql:quickload:lispbuilder-sdl)
(ql:quickload:lispbuilder-sdl-mixer)

(defun mixer-test()
    (sdl:with-init (sdl:sdl-init-video sdl:sdl-init-audio)
        (sdl: window 5010)

        (sdl-mixer: OPEN-AUDIO)
            (let(((sdl-mixer:load-music "konjaku.mp3"))))
                (sdl-mixer:play-music music:loop)

                (sdl:with-events()
                    ( :quit-event()
                                    (sdl-mixer:Halt-Music)
                                    (sdl-mixer:free music)
                                    (sdl-mixer:close-audio)
                                    t)t)
                    (:idle()(sdl:update-display)))))

;(mixer-test)

(ql:quickload:lispbuilder-sdl-mixer-examples)
(sdl-mixer-examples:mixer)
(quit)

The file configuration is as follows:

work/SDL
| - Framework
 | - SDL.dll
 | - SDL_image.dll
 | - SDL_mixer.dll
| -quicklisp
 | - 書き Omitted because I can't finish writing
|- konjaku.mp3
|-mixer.lisp

It seems that the code is incorrect in relation to encoding, but I am having trouble because I do not know which part is incorrect.
Is there a problem with the preprocessing?(Is there any action required before making a call?)
Also, I get the same error for mixer-test function (just the code I picked up from the net).

for print debugging of mixer-test
(let((music(sdl-mixer:load-music "konjaku.mp3"))))

There seemed to be a problem around.
I'm in trouble because I don't know the cause.How do I resolve this?

--Additional --
"Regarding ""konjaku.mp3"", I checked with software called ""Mp3tag"" and found ""UTF-8""."Just to be sure, I prepared a separate UTF-8 write and tried using it, but got the same error.

Regarding the hidden characters ■■■■■ in the log, we only use alphabetic characters.

Below is information about your operating system:

Windows 10 Home 64 Bit

The reason was that the character code was not UTF-8, so I tried to do the following, but only got the same error.

$nkf-w --overwrite mixer.lisp
$nkf-guess mixer.lisp
ASCII
$sbcl --load mixer.lisp
While evaluating the form starting at line 18, column 0
of#P "C:/cygwin64/home/■■■■■/work/SDL/mixer.lisp":

debugger invoked on a BABEL-ENCODINGS:INVALID-UTF8-STARTER-BYTE in thread

Illegal:UTF-8 character starting at position 26.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invocable by number or by positively-abbreviated name):
0—[RETRY] Retry EVAL of current toplevel form.
1:[CONTINUE] Ignore error and continue loading file "C:\cygwin64\home\■■■■■\work\SDL\mixer.lisp".
2:[ABORT] Abort loading file "C:\cygwin64\home\■■■■■\work\SDL\mixer.lisp".
3: Ignore runtime option --load "mixer.lisp".
4:Skip rest of --eval and --load options.
5:Skip to toplevel READ/EVAL/PRINT loop.
6:[EXIT] Exit SBCL (calling#'EXIT, killing the process).

((LABELS BABEL-ENCODINGS::UTF-8-DECODER:IN"C:/cygwin64/home/■■■■■/work/SDL/./quicklisp/dists/quicklisp/software/cffi_0.1/src/string.lisp")#)

Also, I read "quickload", ":cffi", ":lispbuilder-sdl-mixer" on REPL, and then tried to execute the following code, but only got the same error.

(sdl-mixer:load-music
) (merge-pathnames
) "examples/music.mp3"
(asdf:system-source-directory:lispbuilder-sdl-mixer))

If even examples of lispbuilder-sdl-mixer cannot be executed, is there a more fundamental problem?(I don't have a clue...)

common-lisp lisp

2022-09-30 21:18

1 Answers

If you look at the contents of the error, it seems that some characters are incorrect if you read the file in UTF-8.
In this case, it is possible that

I think that is often the case.

Why don't you try something like that?

I think Japanese is often included in the pass, so on REPL,

 (sdl-mixer:load-music) 
 (merge-pathnames)
  "examples/music.mp3"
  (asdf:system-source-directory:lispbuilder-sdl-mixer))

I think it is also effective to experiment with a pass that does not include Japanese.
(The above code can be entered into an open debugger for evaluation and confirmation.)


2022-09-30 21:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.