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