- uint32 jerry_i2s_int_freq = (26591000 / 64) / (jerry_i2s_interrupt_divide + 1);
-//Note: The formula is system_clock_freq / (2 * (N + 1)), and to get 16 bits each of
-// left & right channel, ...
-//
-//WriteLog("SCLK: Setting serial clock freqency to %u Hz...\n", jerry_i2s_int_freq);
-//WriteLog("SCLK: Real serial clock freqency would be %u Hz (N=%u)...\n", 26590906 / (2 * (jerry_i2s_interrupt_divide + 1)), jerry_i2s_interrupt_divide);
-//WTF is this???
- jerry_i2s_interrupt_cycles_per_scanline = 13300000 / jerry_i2s_int_freq;
- jerry_i2s_interrupt_timer = jerry_i2s_interrupt_cycles_per_scanline;
- //WriteLog("jerry: i2s interrupt rate set to %i hz (every %i cpu clock cycles) jerry_i2s_interrupt_divide=%i\n",jerry_i2s_int_freq,jerry_i2s_interrupt_cycles_per_scanline,jerry_i2s_interrupt_divide);
-//No need, we write it directly pcm_set_sample_rate(jerry_i2s_int_freq);
+ // We don't have to divide the RISC clock rate by this--the reason is a bit
+ // convoluted. Will put explanation here later...
+// What's needed here is to find the ratio of the frequency to the number of clock cycles
+// in one second. For example, if the sample rate is 44100, we divide the clock rate by
+// this: 26590906 / 44100 = 602 cycles.
+// Which means, every 602 cycles that go by we have to generate an interrupt.
+ jerryI2SCycles = 32 * (2 * (jerry_i2s_interrupt_divide + 1));