Skip to content

Fm synth#2

Open
DJ-Von wants to merge 2 commits into
tanukiichii:mainfrom
DJ-Von:fm_synth_linux_fix
Open

Fm synth#2
DJ-Von wants to merge 2 commits into
tanukiichii:mainfrom
DJ-Von:fm_synth_linux_fix

Conversation

@DJ-Von
Copy link
Copy Markdown

@DJ-Von DJ-Von commented May 11, 2026

  1. При сборке на linux были ошибки
~/t/fm_synthesis (main)> make
gcc -Wall -Wextra -O2 `sdl2-config --cflags` fm_synth.c -o fm_synth `sdl2-config --libs` -lSDL2_ttf -lm
fm_synth.c: In function ‘main’:
fm_synth.c:179:31: error: initialization of ‘FMod *’ from incompatible pointer type ‘FMod (*)[8]’ [-Wincompatible-pointer-types]
  179 |                     FMod *f = &fm;
      |                               ^
fm_synth.c: In function ‘audio_callback’:
fm_synth.c:399:35: error: passing argument 1 of ‘process_fmod’ from incompatible pointer type [-Wincompatible-pointer-types]
  399 |                 s += process_fmod(&fm, &voices[v]);
      |                                   ^~~
      |                                   |
      |                                   FMod (*)[8]
fm_synth.c:349:26: note: expected ‘FMod *’ but argument is of type ‘FMod (*)[8]’
  349 | float process_fmod(FMod *f, Voice *v)
      |                    ~~~~~~^
fm_synth.c:385:27: warning: unused parameter ‘u’ [-Wunused-parameter]
  385 | void audio_callback(void *u, Uint8 *stream, int len)
      |                     ~~~~~~^
fm_synth.c: In function ‘gen_voice’:
fm_synth.c:345:1: warning: control reaches end of non-void function [-Wreturn-type]
  345 | }
      | ^
fm_synth.c: In function ‘process_fmod’:
fm_synth.c:368:1: warning: control reaches end of non-void function [-Wreturn-type]
  368 | }
      | ^
make: *** [Makefile:16: fm_synth] Error 1
  1. После исправления приложение падало при запуске из-за путей к шрифтам
~/t/fm_synthesis (main)> ./fm_synth 
fish: Job 1, './fm_synth' terminated by signal SIGSEGV (Address boundary error)
  1. FM-модуляция обрабатывалась по голосам через fm[v], но параметры модулятора менялись только через fm[0]. Из-за этого при полифонии часть голосов могла оставаться со старыми значениями betta, ratio, fwave и type.
    Для этого была добавлена sync_fmod_settings(), которая копирует общие настройки модулятора из fm[0] во все fm[i] и пересчитывает freq для каждого голоса. В HARMONIC режиме использует voices[i].freq * ratio, в INHARMONIC режиме использует общую частоту модулятора.

  2. Поправил подсказки ratio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant