1f8903005SMatthias Ringwald /* 2f8903005SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3f8903005SMatthias Ringwald * 4f8903005SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5f8903005SMatthias Ringwald * modification, are permitted provided that the following conditions 6f8903005SMatthias Ringwald * are met: 7f8903005SMatthias Ringwald * 8f8903005SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9f8903005SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10f8903005SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11f8903005SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12f8903005SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13f8903005SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14f8903005SMatthias Ringwald * contributors may be used to endorse or promote products derived 15f8903005SMatthias Ringwald * from this software without specific prior written permission. 16f8903005SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17f8903005SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18f8903005SMatthias Ringwald * monetary gain. 19f8903005SMatthias Ringwald * 20f8903005SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21f8903005SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22f8903005SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23f8903005SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24f8903005SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25f8903005SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26f8903005SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27f8903005SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28f8903005SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29f8903005SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30f8903005SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31f8903005SMatthias Ringwald * SUCH DAMAGE. 32f8903005SMatthias Ringwald * 33f8903005SMatthias Ringwald * Please inquire about commercial licensing options at 34f8903005SMatthias Ringwald * [email protected] 35f8903005SMatthias Ringwald * 36f8903005SMatthias Ringwald */ 37f8903005SMatthias Ringwald 38*e501bae0SMatthias Ringwald #define BTSTACK_FILE__ "mod_player.c" 39bb2a7656SMatthias Ringwald 40f8903005SMatthias Ringwald #include "btstack.h" 41f8903005SMatthias Ringwald #include "hxcmod.h" 42f8903005SMatthias Ringwald #include "mods/mod.h" 43f8903005SMatthias Ringwald 44f8903005SMatthias Ringwald static modcontext mod_context; 45f8903005SMatthias Ringwald 46f8903005SMatthias Ringwald static void audio_playback(int16_t * buffer, uint16_t num_samples){ 47f8903005SMatthias Ringwald hxcmod_fillbuffer(&mod_context, (unsigned short *) buffer, num_samples, NULL); 48f8903005SMatthias Ringwald } 49f8903005SMatthias Ringwald 50f8903005SMatthias Ringwald int btstack_main(int argc, const char * argv[]); 51f8903005SMatthias Ringwald int btstack_main(int argc, const char * argv[]){ 52f8903005SMatthias Ringwald (void)argc; 53f8903005SMatthias Ringwald (void)argv; 54f8903005SMatthias Ringwald 55f8903005SMatthias Ringwald // load mod 56f8903005SMatthias Ringwald int hxcmod_initialized = hxcmod_init(&mod_context); 57f8903005SMatthias Ringwald if (!hxcmod_initialized) return 10; 58f8903005SMatthias Ringwald 59f8903005SMatthias Ringwald hxcmod_setcfg(&mod_context, 44100, 16, 1, 1, 1); 60f8903005SMatthias Ringwald hxcmod_load(&mod_context, (void *) &mod_data, mod_len); 61f8903005SMatthias Ringwald 62f8903005SMatthias Ringwald // setup audio playback 63d365bb51SMatthias Ringwald const btstack_audio_sink_t * audio = btstack_audio_sink_get_instance(); 64f8903005SMatthias Ringwald if (!audio){ 65d365bb51SMatthias Ringwald printf("BTstack Audio Sink not setup\n"); 66f8903005SMatthias Ringwald return 10; 67f8903005SMatthias Ringwald } 68d365bb51SMatthias Ringwald audio->init(2, 44100, &audio_playback); 69f8903005SMatthias Ringwald audio->start_stream(); 70f8903005SMatthias Ringwald 71f8903005SMatthias Ringwald return 0; 72f8903005SMatthias Ringwald } 73