this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

experiment: replace device finding with bonzo's

alice df69844c 8a66f199

+191 -90
+168 -69
src/ext/fft.c
··· 38 38 // kiss_fftr(fftcfg, sampleBuf, fftBuf); 39 39 } 40 40 41 - void FFT_EnumerateDevices(FFT_ENUMERATE_FUNC pEnumerationFunction, void* pUserContext) 42 - { 43 - if (!bCreated) 44 - { 45 - return; 46 - } 41 + // void FFT_EnumerateDevices(FFT_ENUMERATE_FUNC pEnumerationFunction, void* pUserContext) 42 + // { 43 + // if (!bCreated) 44 + // { 45 + // return; 46 + // } 47 47 48 - ma_device_info* pPlaybackDevices = NULL; 49 - ma_device_info* pCaptureDevices = NULL; 50 - ma_uint32 nPlaybackDeviceCount = 0; 51 - ma_uint32 nCaptureDeviceCount = 0; 52 - ma_result result = ma_context_get_devices(&context, &pPlaybackDevices, &nPlaybackDeviceCount, &pCaptureDevices, &nCaptureDeviceCount); 53 - if (result != MA_SUCCESS) 54 - { 55 - printf("[FFT] Failed to enumerate audio devices: %d\n", result); 56 - return; 57 - } 48 + // ma_device_info* pPlaybackDevices = NULL; 49 + // ma_device_info* pCaptureDevices = NULL; 50 + // ma_uint32 nPlaybackDeviceCount = 0; 51 + // ma_uint32 nCaptureDeviceCount = 0; 52 + // ma_result result = ma_context_get_devices(&context, &pPlaybackDevices, &nPlaybackDeviceCount, &pCaptureDevices, &nCaptureDeviceCount); 53 + // if (result != MA_SUCCESS) 54 + // { 55 + // printf("[FFT] Failed to enumerate audio devices: %d\n", result); 56 + // return; 57 + // } 58 58 59 - pEnumerationFunction(true, "<default device>", NULL, pUserContext); 60 - for (ma_uint32 i = 0; i < nCaptureDeviceCount; i++) 61 - { 62 - pEnumerationFunction(true, pCaptureDevices[i].name, &pCaptureDevices[i].id, pUserContext); 63 - } 64 - if (ma_is_loopback_supported(context.backend)) 65 - { 66 - pEnumerationFunction(false, "<default device>", NULL, pUserContext); 67 - for (ma_uint32 i = 0; i < nPlaybackDeviceCount; i++) 68 - { 69 - pEnumerationFunction(false, pPlaybackDevices[i].name, &pPlaybackDevices[i].id, pUserContext); 70 - } 71 - } 72 - } 59 + // pEnumerationFunction(true, "<default device>", NULL, pUserContext); 60 + // for (ma_uint32 i = 0; i < nCaptureDeviceCount; i++) 61 + // { 62 + // pEnumerationFunction(true, pCaptureDevices[i].name, &pCaptureDevices[i].id, pUserContext); 63 + // } 64 + // if (ma_is_loopback_supported(context.backend)) 65 + // { 66 + // pEnumerationFunction(false, "<default device>", NULL, pUserContext); 67 + // for (ma_uint32 i = 0; i < nPlaybackDeviceCount; i++) 68 + // { 69 + // pEnumerationFunction(false, pPlaybackDevices[i].name, &pPlaybackDevices[i].id, pUserContext); 70 + // } 71 + // } 72 + // } 73 73 74 74 void miniaudioLogCallback(void *userData, ma_uint32 level, const char *message) 75 75 { ··· 77 77 return; 78 78 } 79 79 80 - bool FFT_Create() 81 - { 82 - bCreated = false; 83 - ma_context_config context_config = ma_context_config_init(); 84 - ma_log log; 85 - ma_log_init(NULL, &log); 86 - ma_log_register_callback(&log, ma_log_callback_init(miniaudioLogCallback, NULL)); 80 + // bool FFT_Create() 81 + // { 82 + // bCreated = false; 83 + // ma_context_config context_config = ma_context_config_init(); 84 + // ma_log log; 85 + // ma_log_init(NULL, &log); 86 + // ma_log_register_callback(&log, ma_log_callback_init(miniaudioLogCallback, NULL)); 87 87 88 - context_config.pLog = &log; 89 - ma_result result = ma_context_init(NULL, 0, &context_config, &context); 90 - if (result != MA_SUCCESS) 91 - { 92 - printf("[FFT] Failed to initialize context: %d", result); 93 - return false; 94 - } 88 + // context_config.pLog = &log; 89 + // ma_result result = ma_context_init(NULL, 0, &context_config, &context); 90 + // if (result != MA_SUCCESS) 91 + // { 92 + // printf("[FFT] Failed to initialize context: %d", result); 93 + // return false; 94 + // } 95 95 96 - printf("[FFT] MAL context initialized, backend is '%s'\n", ma_get_backend_name(context.backend)); 97 - bCreated = true; 98 - return true; 99 - } 96 + // printf("[FFT] MAL context initialized, backend is '%s'\n", ma_get_backend_name(context.backend)); 97 + // bCreated = true; 98 + // return true; 99 + // } 100 100 101 101 bool FFT_Destroy() 102 102 { ··· 112 112 return true; 113 113 } 114 114 115 - bool FFT_Open(FFT_Settings* pSettings) 115 + 116 + bool FFT_Open(bool CapturePlaybackDevices, const char* CaptureDeviceSearchString) 116 117 { 117 - if (!bCreated) 118 + memset( sampleBuf, 0, sizeof( float ) * FFT_SIZE * 2 ); 119 + 120 + fftcfg = kiss_fftr_alloc( FFT_SIZE * 2, false, NULL, NULL ); 121 + 122 + ma_context_config context_config = ma_context_config_init(); 123 + ma_log log; 124 + ma_log_init(NULL, &log); 125 + ma_log_register_callback(&log, ma_log_callback_init(miniaudioLogCallback, NULL)); 126 + 127 + context_config.pLog = &log; 128 + 129 + ma_result result = ma_context_init( NULL, 0, &context_config, &context ); 130 + if ( result != MA_SUCCESS ) 118 131 { 132 + printf( "[FFT] Failed to initialize context: %d", result ); 119 133 return false; 120 134 } 121 135 122 - memset(sampleBuf, 0, sizeof(float) * FFT_SIZE * 2); 136 + printf( "[FFT] MAL context initialized, backend is '%s'\n", ma_get_backend_name( context.backend ) ); 123 137 124 - fftcfg = kiss_fftr_alloc(FFT_SIZE * 2, false, NULL, NULL); 138 + ma_device_id* TargetDevice = NULL; 125 139 126 140 ma_device_info* pPlaybackDeviceInfos; 127 141 ma_uint32 playbackDeviceCount; 128 142 ma_device_info* pCaptureDeviceInfos; 129 143 ma_uint32 captureDeviceCount; 130 - ma_result result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); 144 + result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); 131 145 if (result != MA_SUCCESS) { 132 146 printf("Failed to retrieve device information.\n"); 133 - return false; 147 + return -3; 134 148 } 135 149 136 150 printf("Playback Devices\n"); 137 151 for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { 138 152 printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); 139 153 } 140 - 154 + 141 155 printf("\n"); 142 156 143 157 printf("Capture Devices\n"); ··· 145 159 printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); 146 160 } 147 161 148 - bool useLoopback = ma_is_loopback_supported(context.backend) && !pSettings->bUseRecordingDevice; 149 - ma_device_config config = ma_device_config_init(useLoopback ? ma_device_type_loopback : ma_device_type_capture); 150 - config.capture.pDeviceID = (ma_device_id*)pSettings->pDeviceID; 162 + // if(strlen(CaptureDeviceSearchString) > 0) { 163 + // if(CapturePlaybackDevices) { 164 + // for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { 165 + // std::string DeviceName = pPlaybackDeviceInfos[iDevice].name; 166 + // if(DeviceName.find(CaptureDeviceSearchString) != std::string::npos ){ 167 + // TargetDevice = &pPlaybackDeviceInfos[iDevice].id; 168 + // break; 169 + // } 170 + // } 171 + // } else { 172 + // for (ma_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) { 173 + // std::string DeviceName = pCaptureDeviceInfos[iDevice].name; 174 + // if(DeviceName.find(CaptureDeviceSearchString) != std::string::npos ){ 175 + // TargetDevice = &pCaptureDeviceInfos[iDevice].id; 176 + // break; 177 + // } 178 + // } 179 + // } 180 + // } 181 + 182 + printf("\n"); 183 + 184 + ma_device_config config = ma_device_config_init( CapturePlaybackDevices ? ma_device_type_loopback : ma_device_type_capture ); 185 + config.capture.pDeviceID = TargetDevice; 151 186 config.capture.format = ma_format_f32; 152 187 config.capture.channels = 2; 153 188 config.sampleRate = 44100; 154 189 config.dataCallback = OnReceiveFrames; 155 190 config.pUserData = NULL; 156 191 157 - result = ma_device_init(&context, &config, &captureDevice); 158 - if (result != MA_SUCCESS) 192 + result = ma_device_init( &context, &config, &captureDevice ); 193 + if ( result != MA_SUCCESS ) 159 194 { 160 - ma_context_uninit(&context); 161 - printf("[FFT] Failed to initialize capture device: %d\n", result); 195 + ma_context_uninit( &context ); 196 + printf( "[FFT] Failed to initialize capture device: %d\n", result ); 162 197 return false; 163 198 } 164 199 165 - printf("[FFT] Selected capture device: %s\n", captureDevice.capture.name); 166 - 167 - result = ma_device_start(&captureDevice); 168 - if (result != MA_SUCCESS) 200 + result = ma_device_start( &captureDevice ); 201 + if ( result != MA_SUCCESS ) 169 202 { 170 - ma_device_uninit(&captureDevice); 171 - ma_context_uninit(&context); 172 - printf("[FFT] Failed to start capture device: %d\n", result); 203 + ma_device_uninit( &captureDevice ); 204 + ma_context_uninit( &context ); 205 + printf( "[FFT] Failed to start capture device: %d\n", result ); 173 206 return false; 174 207 } 175 208 209 + printf( "[FFT] Capturing %s\n", captureDevice.capture.name ); 210 + 176 211 return true; 177 212 } 213 + 214 + // bool FFT_Open(FFT_Settings* pSettings) 215 + // { 216 + // if (!bCreated) 217 + // { 218 + // return false; 219 + // } 220 + 221 + // memset(sampleBuf, 0, sizeof(float) * FFT_SIZE * 2); 222 + 223 + // fftcfg = kiss_fftr_alloc(FFT_SIZE * 2, false, NULL, NULL); 224 + 225 + // ma_device_info* pPlaybackDeviceInfos; 226 + // ma_uint32 playbackDeviceCount; 227 + // ma_device_info* pCaptureDeviceInfos; 228 + // ma_uint32 captureDeviceCount; 229 + // ma_result result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); 230 + // if (result != MA_SUCCESS) { 231 + // printf("Failed to retrieve device information.\n"); 232 + // return false; 233 + // } 234 + 235 + // printf("Playback Devices\n"); 236 + // for (ma_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { 237 + // printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); 238 + // } 239 + 240 + // printf("\n"); 241 + 242 + // printf("Capture Devices\n"); 243 + // for (ma_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) { 244 + // printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); 245 + // } 246 + 247 + // bool useLoopback = ma_is_loopback_supported(context.backend) && !pSettings->bUseRecordingDevice; 248 + // ma_device_config config = ma_device_config_init(useLoopback ? ma_device_type_loopback : ma_device_type_capture); 249 + // config.capture.pDeviceID = (ma_device_id*)pSettings->pDeviceID; 250 + // config.capture.format = ma_format_f32; 251 + // config.capture.channels = 2; 252 + // config.sampleRate = 44100; 253 + // config.dataCallback = OnReceiveFrames; 254 + // config.pUserData = NULL; 255 + 256 + // result = ma_device_init(&context, &config, &captureDevice); 257 + // if (result != MA_SUCCESS) 258 + // { 259 + // ma_context_uninit(&context); 260 + // printf("[FFT] Failed to initialize capture device: %d\n", result); 261 + // return false; 262 + // } 263 + 264 + // printf("[FFT] Selected capture device: %s\n", captureDevice.capture.name); 265 + 266 + // result = ma_device_start(&captureDevice); 267 + // if (result != MA_SUCCESS) 268 + // { 269 + // ma_device_uninit(&captureDevice); 270 + // ma_context_uninit(&context); 271 + // printf("[FFT] Failed to start capture device: %d\n", result); 272 + // return false; 273 + // } 274 + 275 + // return true; 276 + // } 178 277 179 278 void FFT_Close() 180 279 {
+2 -1
src/ext/fft.h
··· 17 17 18 18 bool FFT_Create(); 19 19 bool FFT_Destroy(); 20 - bool FFT_Open(FFT_Settings* pSettings); 20 + // bool FFT_Open(FFT_Settings* pSettings); 21 + bool FFT_Open(bool CapturePlaybackDevices, const char* CaptureDeviceSearchString); 21 22 bool FFT_GetFFT(float* _samples); 22 23 void FFT_Close(); 23 24
+2 -2
src/studio/studio.c
··· 2591 2591 #if defined(BUILD_EDITORS) 2592 2592 if (args.fftlist) 2593 2593 { 2594 - FFT_Create(); 2595 - FFT_EnumerateDevices(print_fft_devices, NULL); 2594 + // FFT_Create(); 2595 + // FFT_EnumerateDevices(print_fft_devices, NULL); 2596 2596 exit(0); 2597 2597 } 2598 2598 studio->config->data.fft = args.fft;
+19 -18
src/system/sdl/main.c
··· 330 330 331 331 if (studio_config(platform.studio)->fft) 332 332 { 333 - FFT_Create(); 334 - FFT_Settings fftSettings; 335 - fftSettings.bUseRecordingDevice = false; 336 - fftSettings.pDeviceID = NULL; 333 + // FFT_Create(); 334 + // FFT_Settings fftSettings; 335 + // fftSettings.bUseRecordingDevice = false; 336 + // fftSettings.pDeviceID = NULL; 337 337 338 - if (studio_config(platform.studio)->fftdevice != NULL) 339 - { 340 - FFT_EnumerateDevices(find_fft_device_by_id, NULL); 341 - if (deviceId != NULL) 342 - { 343 - fftSettings.pDeviceID = deviceId; 344 - } 345 - else 346 - { 347 - printf("Selected device was not found"); 348 - exit(1); 349 - } 350 - } 338 + // if (studio_config(platform.studio)->fftdevice != NULL) 339 + // { 340 + // FFT_EnumerateDevices(find_fft_device_by_id, NULL); 341 + // if (deviceId != NULL) 342 + // { 343 + // fftSettings.pDeviceID = deviceId; 344 + // } 345 + // else 346 + // { 347 + // printf("Selected device was not found"); 348 + // exit(1); 349 + // } 350 + // } 351 351 352 - FFT_Open(&fftSettings); 352 + FFT_Open(false, NULL); 353 + // FFT_Open(&fftSettings); 353 354 } 354 355 355 356 platform.audio.device = SDL_OpenAudioDevice(NULL, 0, &want, &platform.audio.spec, 0);