int main(int argc,char *argv[]) { g_thread_init(0); memset(viewbuf,' ',sizeof(viewbuf)); load(); gtk_init(&argc,&argv); window=gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW (window),"te"); tickcond=g_cond_new(); tickmutex=g_mutex_new(); tick_thread=g_thread_create(tick,0,0,0); g_signal_connect(window,"destroy",G_CALLBACK (gtk_main_quit),NULL); g_signal_connect(window,"key-press-event",G_CALLBACK(on_keypress),NULL); g_signal_connect(window,"key-release-event",G_CALLBACK(on_keyrelease),NULL); gtk_widget_add_events(window,GDK_KEY_PRESS_MASK); GtkWidget *a=gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window),a); g_signal_connect(a,"expose-event",G_CALLBACK(on_expose_event),NULL); gtk_widget_show_all(window); audio_init(); gtk_main(); return 0; }
int main (void) { //Main function int n; for (n=0 ; n< N ; n++) { twiddle[n].real = (float32_t) (cos(PI*n/N)); twiddle[n].imag = (float32_t) (-sin(PI*n/N)); } for (n=0 ; n< N ; n++) { itwiddle[n].real = (float32_t) (cos(PI*n/N)); itwiddle[n].imag = (float32_t) (sin(PI*n/N)); } gpio_set_mode(P2_10,Output); audio_init ( hz48000, line_in, dma, DMA_HANDLER); while(1) { while (!(rx_buffer_full && tx_buffer_empty)) {}; gpio_set(P2_10, HIGH); proces_buffer(); gpio_set(P2_10, LOW); } }
void stop_note(float freq) { if (playing_note) { if (!audio_initialized) { audio_init(); } for (int i = 7; i >= 0; i--) { if (frequencies[i] == freq) { frequencies[i] = 0; volumes[i] = 0; for (int j = i; (j < 7); j++) { frequencies[j] = frequencies[j+1]; frequencies[j+1] = 0; volumes[j] = volumes[j+1]; volumes[j+1] = 0; } break; } } voices--; if (voices < 0) voices = 0; if (voice_place >= voices) { voice_place = 0; } if (voices == 0) { DISABLE_AUDIO_COUNTER_3_ISR; DISABLE_AUDIO_COUNTER_3_OUTPUT; frequency = 0; volume = 0; playing_note = false; } } }
void play_note(float freq, int vol) { if (!audio_initialized) { audio_init(); } if (audio_config.enable && voices < 8) { DISABLE_AUDIO_COUNTER_3_ISR; // Cancel notes if notes are playing if (playing_notes) stop_all_notes(); playing_note = true; envelope_index = 0; if (freq > 0) { frequencies[voices] = freq; volumes[voices] = vol; voices++; } ENABLE_AUDIO_COUNTER_3_ISR; ENABLE_AUDIO_COUNTER_3_OUTPUT; } }
/************************************************** Load a new rom and performs some initialization ***************************************************/ void reloadrom (int size, char *name) { /* cartridge hot-swap support */ uint8 hotswap = 0; if (cart.romsize) hotswap = config.hot_swap; /* Load ROM */ cart.romsize = size; load_rom(name); if (hotswap) { cart_hw_init(); cart_hw_reset(); } else { /* initialize audio back-end */ /* 60hz video mode requires synchronization with Video Interrupt. */ /* VSYNC period is 16715 us on Wii/Gamecube (approx. 802.32 samples per frame) */ float framerate; if (vdp_pal) framerate = 50.0; else framerate = ((config.tv_mode == 0) || (config.tv_mode == 2)) ? (1000000.0/16715.0) : 60.0; audio_init(48000, framerate); /* System Power ON */ system_init (); ClearGGCodes (); system_reset (); } }
void audio_test() { int i=0; long status; audio_init(); while (i < 100000) { status = *(pwm + BCM2835_PWM_STATUS); if (!(status & BCM2835_FULL1)) { /* Decomment this in order to get sound */ /* *(pwm+BCM2835_PWM_FIFO) = audio_data[i]; */ i++; } if ((status & ERRORMASK)) { // uart_print("error: "); // hexstring(status); // uart_print("\r\n"); *(pwm+BCM2835_PWM_STATUS) = ERRORMASK; } } }
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) { if (!audio_initialized) { audio_init(); } if (audio_config.enable) { // Cancel note if a note is playing if (playing_note) { stop_all_notes(); } playing_notes = true; notes_pointer = np; notes_count = n_count; notes_repeat = n_repeat; place = 0; current_note = 0; note_frequency = (*notes_pointer)[current_note][0]; note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); note_position = 0; gptStart(&GPTD8, &gpt8cfg1); gptStartContinuous(&GPTD8, 2U); RESTART_CHANNEL_1(); RESTART_CHANNEL_2(); } }
void play_note(float freq, int vol) { dprintf("audio play note freq=%d vol=%d", (int)freq, vol); if (!audio_initialized) { audio_init(); } if (audio_config.enable && voices < 8) { // Cancel notes if notes are playing if (playing_notes) { stop_all_notes(); } playing_note = true; envelope_index = 0; if (freq > 0) { frequencies[voices] = freq; volumes[voices] = vol; voices++; } gptStart(&GPTD8, &gpt8cfg1); gptStartContinuous(&GPTD8, 2U); RESTART_CHANNEL_1(); RESTART_CHANNEL_2(); } }
int main(int argc, char *argv[]) { //struct sound_params *sp = sg_create_sound_params(SQUARE, sg_create_square_wave_parameters(440, 0.5, SAMPLE_RATE)); struct sound_params *sp2 = sg_create_sound_params(SINE, sg_create_sine_parameters(440, SAMPLE_RATE)); //struct sound_params *sp3 = sg_create_sound_params(SQUARE, sg_create_square_wave_parameters(840, 0.5, SAMPLE_RATE)); audio_init(); audio_create_stream(SAMPLE_RATE); //sound_play_seconds(sp, 0.5); sound_play_seconds(sp2, 1.5); //sound_play_seconds(sp3, 1.5); audio_sleep(1.5*1000); //sp2 = sg_create_sound_params(SQUARE, sg_create_square_wave_parameters(440, 0.5, SAMPLE_RATE)); //sound_play_seconds(sp2, 1); //audio_sleep(1*1000); //sw1.setFrequency(300); audio_shutdown(); return 0; }
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) { if (!audio_initialized) { audio_init(); } if (audio_config.enable) { DISABLE_AUDIO_COUNTER_3_ISR; // Cancel note if a note is playing if (playing_note) stop_all_notes(); playing_notes = true; notes_pointer = np; notes_count = n_count; notes_repeat = n_repeat; notes_rest = n_rest; place = 0; current_note = 0; note_frequency = (*notes_pointer)[current_note][0]; note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); note_position = 0; ENABLE_AUDIO_COUNTER_3_ISR; ENABLE_AUDIO_COUNTER_3_OUTPUT; } }
int main(int argc, char *argv[]) { video_init(0); audio_init(argc, argv); game_init(); double last = glfwGetTime(); while (running) { double current = glfwGetTime(); int delta = (current - last) * 1000; if (delta < MIN_DELTA) { glfwSleep((MIN_DELTA-delta)/1000.0); continue; } last = current; now += delta; if (delta > MAX_DELTA) continue; game_tick(delta); } audio_shutdown(); video_shutdown(); return EXIT_SUCCESS; }
static void connect_to_peripherals() { /** @todo Finalize start up sequence and define better self tests for each peripheral.*/ init_Bluetooth_to_PIU(); self_test_passed = bluetooth_to_PIU_online; init_Bluetooth_to_remote(); self_test_passed = (self_test_passed & bluetooth_to_remote_online); audio_init(); self_test_passed = (self_test_passed & audio_controller_online); // All tests passed? if (self_test_passed) { // Play success pattern LED_play_pattern(LED_SELF_TEST_PASSED); } else { // Play fail pattern on repeat LED_play_pattern(LED_SELF_TEST_FAILED); } }
void init_system(void) { /* keep mosfet closed to ground (circuit on) */ gpio_pre_init(); /* timing first, needed for all delays */ systick_init(); /* get globalb config */ config_read(); lcd_init_gpio(); lcd_init_fsmc(); /* lcd inid always before touch_init, since it resets lcd */ lcd_init(); ui_init(); gpio_init(); adc_init(); audio_init(); rtc_init(); touch_init(); }
int init(void) { // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } set_led(0); // off by default // make sure SDL cleans up before exit atexit(SDL_Quit); // create a default new window set_mode(VGA_H_PIXELS,VGA_V_PIXELS); #ifndef NO_AUDIO audio_init(); #endif joy_init(); next_time = SDL_GetTicks(); if (!quiet) printf("Screen is now %dx%d with a scale of %d\n",screen_width,screen_height,scale); SDL_ShowCursor(SDL_DISABLE); return 0; }
void audio_start(unsigned int rate, unsigned int channel_count) { audio_init(); snd_pcm_prepare(playback_handle); }
static void alccapturestart(void *handle) { if(handle == (void*)1) { audio_init(handle); return; } alcCaptureStart(handle); }
int init(void) { // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } set_led(0); // off by default // make sure SDL cleans up before exit atexit(SDL_Quit); // create a default new window set_mode(VGA_H_PIXELS,VGA_V_PIXELS); #ifndef NO_AUDIO audio_init(); #endif joy_init(); next_time = SDL_GetTicks(); printf("screen is now %dx%d\n",screen_width,screen_height); #ifdef MICROKERNEL printf("Using 8Bpp interface (micro)"); #endif return 0; }
int main(void) { sp_error error; sp_session *session; // create the spotify session spconfig.application_key_size = g_appkey_size; error = sp_session_create(&spconfig, &session); if (error != SP_ERROR_OK) { fprintf(stderr, "Unable to create session: %s\n", sp_error_message(error)); return 1; } // initialize audio audio_init(&g_audiofifo); // log in g_logged_in = 0; sp_session_login(session, username, password, 0, NULL); // main loop g_playing = 0; g_running = 1; int next_timeout = 0; while (g_running) { sp_session_process_events(session, &next_timeout); if (g_logged_in && !g_playing) { run_search(session); g_playing = 1; } } return 0; }
int hdmi_test(struct test_Parameters *test_para) { test_words_show("HDMI test",Bcolor); /*if(init_tvout_pic() < 0)*/ /*{*/ /*draw_decision_pic(FAIL);*/ /*return False;*/ /*}*/ #ifdef H350 if(audio_init(SAMPLINGRATE, O_WRONLY) < 0) return False; if(init_fb(test_para->hdmi_info.buffer_size) < 0) { draw_decision_pic(FAIL); return False; } if (test_hdmi_loop(test_para) != True) { draw_decision_pic(FAIL); return False; } deinit_audio(); deinit_fb(test_para->hdmi_info.buffer_size); #endif /*deinit_tvout_pic();*/ return decision_loop(); }
void stop_all_notes() { dprintf("audio stop all notes"); if (!audio_initialized) { audio_init(); } voices = 0; #ifdef CPIN_AUDIO DISABLE_AUDIO_COUNTER_3_ISR; DISABLE_AUDIO_COUNTER_3_OUTPUT; #endif #ifdef BPIN_AUDIO DISABLE_AUDIO_COUNTER_1_ISR; DISABLE_AUDIO_COUNTER_1_OUTPUT; #endif playing_notes = false; playing_note = false; frequency = 0; frequency_alt = 0; volume = 0; for (uint8_t i = 0; i < 8; i++) { frequencies[i] = 0; volumes[i] = 0; } }
void stm32_soc_init(void) { HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /**Configure the Systick interrupt time */ HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/RHINO_CONFIG_TICKS_PER_SECOND); /*default uart init*/ stduart_init(); brd_peri_init(); MX_DMA_Init(); MX_SAI1_Init(); MX_SPI1_Init(); MX_CRC_Init(); #ifdef STARTERKIT_AUDIO drv_codec_nau8810_init(); audio_init(); #endif }
/* initializes some needed variables */ void init(void) { FILE *f = fopen("log.spotify", "wb"); fclose(f); sp_error error; sp_session *session; username = malloc(sizeof(char)*30); password = malloc(sizeof(char)*30); audio_init(&g_audiofifo); session_config.application_key_size = g_appkey_size; pthread_mutex_init(¬ify_mutex, NULL); pthread_cond_init(¬ify_cond, NULL); pthread_cond_init(&promt_cond, NULL); queue_entry = malloc(sizeof(q_entry)); queue_entry->size = 0; queue_entry->is_playing = FALSE; queue_entry->head = NULL; queue_entry->tail = NULL; /* create the spotify session */ error = sp_session_create(&session_config, &session); if (error != SP_ERROR_OK) { fprintf(stderr, "Error: unable to create spotify session: %s\n", sp_error_message(error)); return; } g_session = session; }
int main(int argc, char *argv[]) { SDL_Surface* screen = NULL, *menu = NULL; SDL_Rect positionMenu; SDL_Event event; int continuer = 1; audio_init(); audio_play(1); SDL_Init(SDL_INIT_VIDEO); SDL_WM_SetIcon(IMG_Load("images/Mario.png"), NULL); // L'icône doit être chargée avant SDL_SetVideoMode screen = SDL_SetVideoMode(600, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); //Ouvre la page SDL_WM_SetCaption("Super Mario BROS", NULL); //Définit le titre menu = IMG_Load("images/menu.jpg"); //Charge l'image du menu positionMenu.x = screen->w / 2 - menu->w / 2; //Définit le menu au centre de la fenêtre positionMenu.y = 0; while (continuer) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: continuer = 0; break; case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_ESCAPE: continuer = 0; break; case SDLK_1: game(screen); screen = SDL_SetVideoMode(600, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); break; case SDLK_2: credits(screen); break; } break; } SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); //Fond noir SDL_BlitSurface(menu, NULL, screen, &positionMenu); //Imprime le menu sur la page SDL_Flip(screen); } audio_stop(); SDL_FreeSurface(menu); //Efface le menu SDL_Quit(); //Quitte return EXIT_SUCCESS; }
static int ak4671_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct ak4671_setup_data *setup; struct snd_soc_codec *codec; struct ak4671_priv *ak4671; int ret = 0; printk(KERN_INFO "AK4671 Audio Codec %s", AK4671_VERSION); /* Board Specific function */ audio_init(); if (amp_init() < 0) printk("amp init failed.\n"); audio_power(1); ak4671_power = 1; amp_set_path(AK4671_AMP_PATH_SPK); mic_set_path(AK4671_MIC_PATH_MAIN); ret = device_create_file(&pdev->dev, &dev_attr_ak4671_control); setup = socdev->codec_data; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; ak4671 = kzalloc(sizeof(struct ak4671_priv), GFP_KERNEL); if (ak4671 == NULL) { kfree(codec); return -ENOMEM; } codec->private_data = ak4671; socdev->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); ak4671_socdev = socdev; #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) if (setup->i2c_address) { normal_i2c[0] = setup->i2c_address; codec->hw_write = (hw_write_t)i2c_master_send; codec->hw_read = (hw_read_t)i2c_master_recv; ret = i2c_add_driver(&ak4671_i2c_driver); if (ret != 0) printk(KERN_ERR "can't add i2c driver"); } #else /* Add other interfaces here */ #endif if (ret != 0) { kfree(codec->private_data); kfree(codec); } return ret; }
int main(int argc, char **argv) { PaStream *stream; sound data; writer wargs; pthread_t file_write_thread, wave_viewer, crude_detector; //wunused (void) argc; (void) argv; if (argc >= 2 && *argv[1] == 'r'){ png_view_create("out/record.dog","waveform.png"); return 0; } signal(SIGINT, shutdown); wargs.df = create_dogfile("out/record.dog", DF_COMPRESSED, DF_LOSSLESS); wargs.data = &data; audio_init(&stream, &data); audio_start(stream); if (pthread_create(&file_write_thread, NULL, file_writer, &wargs)){ fprintf(stderr, "Error creating file writer\n"); close(); close_file(wargs.df); exit(1); } if (argc >= 2 && *argv[1] == 'n'){ nc_setup(); if (pthread_create(&wave_viewer, NULL, nc_view, &data)){ fprintf(stderr, "Error creating waveform viewer\n"); nc_stop(); close(); close_file(wargs.df); exit(1); } } detection_start(); if (pthread_create(&crude_detector, NULL, detect, &data)){ fprintf(stderr, "Error creating detection thread\n"); nc_stop(); close(); close_file(wargs.df); exit(1); } audio_wait(stream); //nc_stop(); close(); close_file(wargs.df); return 0; }
void sess_init() { if (!despotify_init()) panic("despotify_init() failed"); audio_device = audio_init(); log_append("Initialized audio output"); }
/* * create an audio context * args: * api - audio api * * asserts: * none * * returns: pointer to audio context data */ audio_context_t *create_audio_context(int api) { close_audio_context(); my_audio_ctx = audio_init(api); return my_audio_ctx; }
int main(void) { gpio_set_mode(P2_10,Output); arm_lms_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], beta, BLOCK_SIZE); audio_init ( hz8000, line_in, intr, I2S_HANDLER); while(1){} }
int audio_write(struct mad_pcm *pcm, error_t *error) { if (!audio_initialized) { audio.channels = pcm->channels; audio.samplerate = pcm->samplerate; if (!audio_init(error)) { error_prepend(error, "Could not initialize audio"); return 0; } } if ((audio.channels != pcm->channels) || (audio.samplerate != pcm->samplerate)) { /* XXX */ error_set(error, "Changing the audio parameters is not supported"); return 0; } if (pcm->length != 1152) { error_printf(error, "Unknown number of samples in the mad buffer: %d", pcm->length); return 0; } if (pcm->channels != 2) { error_set(error, "Only stereo PCM data supported"); return 0; } int ret; float buf[1152 * pcm->channels]; float *ptr = buf; int i; mad_fixed_t const *left_ch, *right_ch; left_ch = pcm->samples[0]; right_ch = pcm->samples[1]; for (i = 0; i < pcm->length; i++) { signed int sample; *ptr++ = mad_scale(*left_ch++) / 32768.0; *ptr++ = mad_scale(*right_ch++) / 32768.0; } ret = rb_enqueue(&audio.rb, buf, 1152 * pcm->channels); if (ret == 0) { error_set(error, "Could not enqueue the PCM samples"); return 0; } if (!audio_started) { ret = AudioDeviceStart(audio.device, audio_play_proc); if (ret) { error_set(error, "Could not start the audio playback"); return 0; } audio_started = 1; } return 1; }
void matrix_init_quantum() { #ifdef BACKLIGHT_ENABLE backlight_init_ports(); #endif #ifdef AUDIO_ENABLE audio_init(); #endif matrix_init_kb(); }