diff --git a/gnu/local.mk b/gnu/local.mk
index 4566f1b4a4..6833df10db 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -872,6 +872,7 @@ MODULES_NOT_COMPILED +=				\
 
 patchdir = $(guilemoduledir)/%D%/packages/patches
 dist_patch_DATA =						\
+  %D%/packages/patches/a2jmidid-enable-riscv-build.patch	\
   %D%/packages/patches/abcl-fix-build-xml.patch	\
   %D%/packages/patches/ableton-link-system-libraries-debian.patch	\
   %D%/packages/patches/abiword-explictly-cast-bools.patch	\
diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 5069e6f0df..9017966f2f 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -54,6 +54,7 @@
 ;;; Copyright © 2023 Antero Mejr <antero@mailbox.org>
 ;;; Copyright © 2023 Sharlatan Hellseher <sharlatanus@gmail.com>
 ;;; Copyright © 2023 Yovan Naumovski <yovan@gorski.stream>
+;;; Copyright © 2023 Zheng Junjie <873216071@qq.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -7014,20 +7015,20 @@ (define-public a2jmidid
                     (commit version)))
               (sha256
                (base32 "1x6rcl3f4nklnx4p5jln9a7fpj9y7agjxs9rw7cccmwnski7pnsq"))
-              (file-name (git-file-name name version))))
+              (file-name (git-file-name name version))
+              ;; https://github.com/jackaudio/a2jmidid/pull/18
+              (patches (search-patches "a2jmidid-enable-riscv-build.patch"))))
     (arguments
-     `(#:tests? #f      ; No tests.
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'install 'wrap-programs
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (bin (string-append out "/bin/")))
-               (substitute* (string-append bin "a2j")
-                 (("a2j_control") (string-append bin "a2j_control")))
-               (wrap-program (string-append bin "a2j_control")
-                `("PYTHONPATH" prefix (,(getenv "GUIX_PYTHONPATH"))))
-               #t))))))
+     (list #:tests? #f      ; No tests.
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'install 'wrap-programs
+                 (lambda* (#:key inputs outputs #:allow-other-keys)
+                   (let ((bin (string-append #$output "/bin/")))
+                     (substitute* (string-append bin "a2j")
+                       (("a2j_control") (string-append bin "a2j_control")))
+                     (wrap-program (string-append bin "a2j_control")
+                       `("PYTHONPATH" prefix (,(getenv "GUIX_PYTHONPATH"))))))))))
     (build-system meson-build-system)
     (inputs
      (list alsa-lib
diff --git a/gnu/packages/patches/a2jmidid-enable-riscv-build.patch b/gnu/packages/patches/a2jmidid-enable-riscv-build.patch
new file mode 100644
index 0000000000..2b9e2ed1c5
--- /dev/null
+++ b/gnu/packages/patches/a2jmidid-enable-riscv-build.patch
@@ -0,0 +1,44 @@
+From 2c3fbef6854743416d95d85b1565dde51668488c Mon Sep 17 00:00:00 2001
+From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
+Date: Fri, 1 Oct 2021 16:15:29 +0200
+Subject: [PATCH] sigsegv: enable RISC-V build
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Avoid build error
+
+../sigsegv.c:104:39: error: ‘mcontext_t’ has no member named ‘gregs’;
+did you mean ‘__gregs’?
+  104 |                 ucontext->uc_mcontext.gregs[i]
+      |                                       ^~~~~
+
+Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
+---
+ sigsegv.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/sigsegv.c b/sigsegv.c
+index fb4456e..6930185 100644
+--- a/sigsegv.c
++++ b/sigsegv.c
+@@ -91,7 +91,9 @@ static void signal_segv(int signum, siginfo_t* info, void*ptr) {
+     a2j_error("info.si_errno = %d", info->si_errno);
+     a2j_error("info.si_code  = %d (%s)", info->si_code, si_codes[info->si_code]);
+     a2j_error("info.si_addr  = %p", info->si_addr);
+-#if !defined(__alpha__) && !defined(__ia64__) && !defined(__FreeBSD_kernel__) && !defined(__arm__) && !defined(__hppa__) && !defined(__sh__) && !defined(__aarch64__)
++#if !defined(__alpha__) && !defined(__ia64__) && \
++    !defined(__FreeBSD_kernel__) && !defined(__arm__) && !defined(__hppa__) && \
++    !defined(__sh__) && !defined(__aarch64__) && !defined(__riscv)
+     for(i = 0; i < NGREG; i++)
+         a2j_error("reg[%02d]       = 0x" REGFORMAT, i,
+ #if defined(__powerpc__) && !defined(__powerpc64__)
+@@ -108,7 +110,7 @@ static void signal_segv(int signum, siginfo_t* info, void*ptr) {
+                 ucontext->uc_mcontext.gregs[i]
+ #endif
+                 );
+-#endif /* alpha, ia64, kFreeBSD, arm, hppa, aarch64 */
++#endif /* alpha, ia64, kFreeBSD, arm, hppa, aarch64, riscv */
+ 
+ #if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64)
+ # if defined(SIGSEGV_STACK_IA64)
