arduino-audio-tools
Loading...
Searching...
No Matches
Time.h
Go to the documentation of this file.
1#pragma once
3#include <iostream>
4#include <thread>
5
6#ifndef DESKTOP_MILLIS_DEFINED
7#define DESKTOP_MILLIS_DEFINED
8
9namespace audio_tools {
10
13 using namespace std::chrono;
14 // Get current time with precision of milliseconds
15 auto now = time_point_cast<milliseconds>(system_clock::now());
16 // sys_milliseconds is type time_point<system_clock, milliseconds>
17 using sys_milliseconds = decltype(now);
18 // Convert time_point to signed integral type
19 return now.time_since_epoch().count();
20}
21
22// sleep ms milliseconds
23void delay(unsigned long ms){
24 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
25}
26
27// sleep us milliseconds
28void delayMicroseconds(unsigned int us){
29 std::this_thread::sleep_for(std::chrono::microseconds(us));
30}
31
32// Returns the micros of milliseconds passed since epich
33inline unsigned long micros(void){
34 using namespace std::chrono;
35 // Get current time with precision of milliseconds
36 auto now = time_point_cast<microseconds>(system_clock::now());
37 // sys_milliseconds is type time_point<system_clock, milliseconds>
38 using sys_milliseconds = decltype(now);
39 // Convert time_point to signed integral type
40 return now.time_since_epoch().count();
41}
42
43}
44
45#endif
If you want to use the framework w/o Arduino you need to provide the implementation of a couple of cl...
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
void delayMicroseconds(unsigned int us)
Definition Time.h:28
void delay(unsigned long ms)
Definition Time.h:23
unsigned long micros(void)
Definition Time.h:33
uint32_t millis()
Returns the milliseconds since the start.
Definition Time.h:12
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:512