{"id":2347,"date":"2025-03-13T01:15:39","date_gmt":"2025-03-12T23:15:39","guid":{"rendered":"https:\/\/www.julien-nevo.com\/arkostracker\/?page_id=2347"},"modified":"2026-05-06T22:53:17","modified_gmt":"2026-05-06T20:53:17","slug":"using-cpctelera-with-at3","status":"publish","type":"page","link":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/using-cpctelera-with-at3\/","title":{"rendered":"Using CPCtelera with AT3"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>This article is by Arnaud. Thanks to him!<\/em><br><br>The objective of this tutorial is to use music and sounds created by Arkos Tracker 3 with the CPCTelera development environment.<br><br>Many games use this environment, for example the winner of&nbsp;<strong>CPCRetroDev 2020<\/strong>&nbsp;<em>The abduction of Oscar Z (Dreamin`Bits)<\/em>,&nbsp;<em>Sorcerers (SalvaKantero)<\/em>&nbsp;second place of CPCRetroDev 2020 or&nbsp;<em>Space Movies (RetroBytes)<\/em>. Most of the CPCRetrodev participants use this Framework.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Arkos Tracker 3 is natively integrated into CPCTeleraNext<\/strong>. Music and sound effects are generated by editing the associated configuration file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is essentially the same process as integrating ArkosTracker 1 with CPCtelera, but with CPCTeleraNext, only AT3 is supported, and the implementation is slightly different.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the repository:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/Arnaud6128\/cpctelera\/tree\/cpctelera_next\">https:\/\/github.com\/Arnaud6128\/cpctelera\/tree\/cpctelera_next<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All functions are documented in the help section, under Audio.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The example is in the following directory <em>\u00ab&nbsp;<\/em>cpctelera\/examples\/medium\/arkosAudio<em>&nbsp;\u00bb<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the &#8220;cfg\/&#8221; directory of your project, the &#8220;music_conversion.mk&#8221; file generates the sounds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are the different parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SET_FOLDER: specifies where to generate the music; by default, this is in the src\/ directory.<\/li>\n\n\n\n<li>SET_PLAYER: specifies the Player (akg, akm, and fx). Special effects are linked to the selected Player.<\/li>\n\n\n\n<li>SET_OUTPUTS: specifies the output format &#8220;s&#8221; for assembly language output (SDCC compatible) and binary output &#8220;bin&#8221; as an array in a C file. For binary output, you will need to specify the memory address of the sound; for assembly language, the compiler will handle this automatically.<\/li>\n\n\n\n<li>CONVERT: launches the sound generation process. You must specify the path of the \u00ab&nbsp;aks&nbsp;\u00bb file, the name of the sound variable in the code, and its address for binary generation.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"> In the example provided, here is the content of the &#8220;music_conversion.mk&#8221; file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$(eval $(call AKS2DATA, SET_OUTPUTS , bin ))\n$(eval $(call AKS2DATA, SET_PLAYER , akg ))\n$(eval $(call AKS2DATA, CONVERT , music\/molusk.aks , music , 0x300))\n$(eval $(call AKS2DATA, SET_OUTPUTS , s ))\n$(eval $(call AKS2DATA, SET_PLAYER , fx ))\n$(eval $(call AKS2DATA, CONVERT , music\/sfx.aks , effects , ))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see, the AKG Player is used, the music is generated in binary at address 0x300 in the variable \u00ab&nbsp;music&nbsp;\u00bb, and the sound is generated in assembly language in the variable \u00ab&nbsp;effects&nbsp;\u00bb. The generated files are named as the input AKS file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To start the generation process, simply enter the command <em>make<\/em>, which will execute the script and then compile the project.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8220;src\/&#8221; directory (specified by default) will contain all generated files:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>molusk.c<\/li>\n\n\n\n<li>molusk.h<\/li>\n\n\n\n<li>sfx.s<\/li>\n\n\n\n<li>sfx.h<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Music generation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The \u00ab&nbsp;molusk.c&nbsp;\u00bb file contains the music named \u00ab&nbsp;g_music&nbsp;\u00bb and the variable is accessible via the \u00ab&nbsp;molusk.h&nbsp;\u00bb file. The binary generation will automatically prefix the variable with \u00ab&nbsp;g_&nbsp;\u00bb.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A macro is used to position the music at 0x300.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Generated by CPCTelera for ArkosPlayer3\n#include &lt;cpctelera.h&gt;\nCPCT_ABSOLUTE_LOCATION_AREA(0x2FF); \/\/ Array at 0x300 \n\/\/ File src\/molusk.bin converted using cpct_bin2c\nconst unsigned char g_music&#91;7841] = {\n\u2026<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Sound effectusic generation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>The \u00ab&nbsp;sfx.s&nbsp;\u00bb file contains all the sound effects and they are used in the code in \u00ab&nbsp;sfx.h&nbsp;\u00bb. The sound effects are automatically suffixed with \u00ab&nbsp;SoundEffects&nbsp;\u00bb.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Generated by CPCTelera for ArkosPlayer3\nextern u8 effectsSoundEffects&#91;];<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Implementing the AKG Player<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the \u00ab&nbsp;main.c&nbsp;\u00bb file, the generated code is included and the ArkosTracker 3 functions are used.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The generated files shall be included&nbsp;in this way :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include \"molusk.h\"\n#include \"sfx.h\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In our case, we used the AKG Player, but the logic is the same with the AKM Player, the only difference is the function prefix, you will need to use <em>cpct_PLY_AKG&lt;function&gt;<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As always, the sounds must be initialized before using them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Initialize the song to be played\ncpct_PLY_AKG_Init(g_music, 0); \/\/ Initialize the music\ncpct_PLY_AKG_InitSoundEffects(effectsSoundEffects); \/\/ Initialize the sound effects\n\/\/ Music is played on interrupt.\ncpct_setInterruptHandler(MusicInterruptHandler);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the example, an interrupt is used to play the sound, which guarantees a frequency of 50Hz.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <em>cpct_PLY_AKG_Play<\/em> method will allow the selected music and sound effect to be played.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void MusicInterruptHandler(void)\n{\n\n    static u8 sInterrupt = 0;\n\n    \/\/ Play next music 1\/50 step.\n    if (sInterrupt == 1)\n    {\n        if (gPlaying)\n            cpct_PLY_AKG_Play();\n    }\n    else if (sInterrupt == 6)\n    {\n        cpct_scanKeyboard_if();\n        sInterrupt = 0;\n    }\n\n    sInterrupt++;\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">In the main loop:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pressing 1 or 2 plays the associated sound using the <em>cpct_PLY_AKG_PlaySoundEffect<\/em> function.<\/li>\n\n\n\n<li>Pressing the spacebar stops all sounds using the <em>cpct_PLY_AKG_Stop function<\/em> or plays another sound.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  while (1) \n   {\n       \/\/ When Space is released, stop \/ continue music\n       if ( checkKeyEvent(Key_Space, &amp;k_space) == K_RELEASED ) \n       {                       \n           \/\/ Change it from playing to not playing and viceversa (0 to 1, 1 to 0)\n           gPlaying ^= 1;\n           \n           \/\/ Stop sound\n           if (!gPlaying){\n               cpct_PLY_AKG_Stop(); \/\/ Cut down sound output\n           }\n           else{\n               cpct_PLY_AKG_PlaySoundEffect(1, AT3_CHANNEL_A, 0); \/\/ Play sound\n           }\n       } \n\n       \/\/ Play sound effect when press key 1, or 2\n       \/\/ !! Warning sound effect start at index 1 !!\n       if ( checkKeyEvent(Key_1, &amp;k_1) == K_RELEASED ) \n       {\n           cpct_PLY_AKG_PlaySoundEffect(2, AT3_CHANNEL_A, 0);\n       } \n\n       if ( checkKeyEvent(Key_2, &amp;k_2) == K_RELEASED ) \n       {\n           cpct_PLY_AKG_PlaySoundEffect(3, AT3_CHANNEL_A, 0);\n       } \n   }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><br> Using ArkosTracker Player is quite simple, for more information on Player functions consult the documentation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article is by Arnaud. Thanks to him! The objective of this tutorial is to use music and sounds created by Arkos [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":214,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"class_list":["post-2347","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/pages\/2347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/comments?post=2347"}],"version-history":[{"count":9,"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/pages\/2347\/revisions"}],"predecessor-version":[{"id":3166,"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/pages\/2347\/revisions\/3166"}],"wp:attachment":[{"href":"https:\/\/www.julien-nevo.com\/arkostracker\/index.php\/wp-json\/wp\/v2\/media?parent=2347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}