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 38f8903005SMatthias Ringwald #include "btstack.h" 39f8903005SMatthias Ringwald #include "hxcmod.h" 40f8903005SMatthias Ringwald #include "mods/mod.h" 41f8903005SMatthias Ringwald 42f8903005SMatthias Ringwald static modcontext mod_context; 43f8903005SMatthias Ringwald 44f8903005SMatthias Ringwald static void audio_playback(int16_t * buffer, uint16_t num_samples){ 45f8903005SMatthias Ringwald hxcmod_fillbuffer(&mod_context, (unsigned short *) buffer, num_samples, NULL); 46f8903005SMatthias Ringwald } 47f8903005SMatthias Ringwald 48f8903005SMatthias Ringwald int btstack_main(int argc, const char * argv[]); 49f8903005SMatthias Ringwald int btstack_main(int argc, const char * argv[]){ 50f8903005SMatthias Ringwald (void)argc; 51f8903005SMatthias Ringwald (void)argv; 52f8903005SMatthias Ringwald 53f8903005SMatthias Ringwald // load mod 54f8903005SMatthias Ringwald int hxcmod_initialized = hxcmod_init(&mod_context); 55f8903005SMatthias Ringwald if (!hxcmod_initialized) return 10; 56f8903005SMatthias Ringwald 57f8903005SMatthias Ringwald hxcmod_setcfg(&mod_context, 44100, 16, 1, 1, 1); 58f8903005SMatthias Ringwald hxcmod_load(&mod_context, (void *) &mod_data, mod_len); 59f8903005SMatthias Ringwald 60f8903005SMatthias Ringwald // setup audio playback 61*d365bb51SMatthias Ringwald const btstack_audio_sink_t * audio = btstack_audio_sink_get_instance(); 62f8903005SMatthias Ringwald if (!audio){ 63*d365bb51SMatthias Ringwald printf("BTstack Audio Sink not setup\n"); 64f8903005SMatthias Ringwald return 10; 65f8903005SMatthias Ringwald } 66*d365bb51SMatthias Ringwald audio->init(2, 44100, &audio_playback); 67f8903005SMatthias Ringwald audio->start_stream(); 68f8903005SMatthias Ringwald 69f8903005SMatthias Ringwald return 0; 70f8903005SMatthias Ringwald } 71