mirror of
https://github.com/danog/system-bus-radio.git
synced 2024-12-02 20:57:44 +01:00
fix whitespace
This commit is contained in:
parent
b09a87a9da
commit
95a64bbe76
100
main.c
100
main.c
@ -15,64 +15,64 @@ mach_port_t clock_port;
|
||||
mach_timespec_t remain;
|
||||
|
||||
static inline void square_am_signal(float time, float frequency) {
|
||||
printf("Playing / %0.3f seconds / %4.0f Hz\n", time, frequency);
|
||||
uint64_t period = NSEC_PER_SEC / frequency;
|
||||
printf("Playing / %0.3f seconds / %4.0f Hzn", time, frequency);
|
||||
uint64_t period = NSEC_PER_SEC / frequency;
|
||||
|
||||
uint64_t start = mach_absolute_time();
|
||||
uint64_t end = start + time * NSEC_PER_SEC;
|
||||
uint64_t start = mach_absolute_time();
|
||||
uint64_t end = start + time * NSEC_PER_SEC;
|
||||
|
||||
while (mach_absolute_time() < end) {
|
||||
uint64_t mid = start + period / 2;
|
||||
uint64_t reset = start + period;
|
||||
while (mach_absolute_time() < mid) {
|
||||
_mm_stream_si128(®, reg_one);
|
||||
_mm_stream_si128(®, reg_zero);
|
||||
while (mach_absolute_time() < end) {
|
||||
uint64_t mid = start + period / 2;
|
||||
uint64_t reset = start + period;
|
||||
while (mach_absolute_time() < mid) {
|
||||
_mm_stream_si128(®, reg_one);
|
||||
_mm_stream_si128(®, reg_zero);
|
||||
}
|
||||
clock_sleep_trap(clock_port, TIME_ABSOLUTE, reset / NSEC_PER_SEC, reset % NSEC_PER_SEC, &remain);
|
||||
start = reset;
|
||||
}
|
||||
clock_sleep_trap(clock_port, TIME_ABSOLUTE, reset / NSEC_PER_SEC, reset % NSEC_PER_SEC, &remain);
|
||||
start = reset;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
mach_timebase_info_data_t theTimeBaseInfo;
|
||||
mach_timebase_info(&theTimeBaseInfo);
|
||||
puts("TESTING TIME BASE: the following should be 1 / 1");
|
||||
printf(" Mach base: %u / %u nanoseconds\n\n", theTimeBaseInfo.numer, theTimeBaseInfo.denom);
|
||||
mach_timebase_info_data_t theTimeBaseInfo;
|
||||
mach_timebase_info(&theTimeBaseInfo);
|
||||
puts("TESTING TIME BASE: the following should be 1 / 1");
|
||||
printf(" Mach base: %u / %u nanosecondsnn", theTimeBaseInfo.numer, theTimeBaseInfo.denom);
|
||||
|
||||
uint64_t start = mach_absolute_time();
|
||||
uint64_t end = mach_absolute_time();
|
||||
printf("TESTING TIME TO EXECUTE mach_absolute_time()\n Result: %lld nanoseconds\n\n", end - start);
|
||||
uint64_t start = mach_absolute_time();
|
||||
uint64_t end = mach_absolute_time();
|
||||
printf("TESTING TIME TO EXECUTE mach_absolute_time()n Result: %lld nanosecondsnn", end - start);
|
||||
|
||||
reg_zero = _mm_set_epi32(0, 0, 0, 0);
|
||||
reg_one = _mm_set_epi32(-1, -1, -1, -1);
|
||||
reg_zero = _mm_set_epi32(0, 0, 0, 0);
|
||||
reg_one = _mm_set_epi32(-1, -1, -1, -1);
|
||||
|
||||
while (1) {
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2093);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.790, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.790, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 3136);
|
||||
square_am_signal(0.790, 3136);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2093);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.790, 2093);
|
||||
}
|
||||
while (1) {
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2093);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.790, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.790, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 3136);
|
||||
square_am_signal(0.790, 3136);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2093);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.400, 2673);
|
||||
square_am_signal(0.400, 2349);
|
||||
square_am_signal(0.790, 2093);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user