---
title: CMClock
framework: coremedia
role: symbol
role_heading: Class
path: coremedia/cmclock
---

# CMClock

An object that represents a source of time.

## Declaration

```swift
class CMClock
```

## Overview

Overview A clock represents a source of time information: a piece of hardware that measures the passage of time. One example of a clock is the host time clock, accessible via CMClockGetHostTimeClock(). It measures time using the CPU system clock, which in macOS is mach_absolute_time(). Every audio device is also a clock because the audio samples that it outputs or inputs each have a defined duration (for example, 1/48000 of a second for 48 kHz audio). CMClocks are read-only; they cannot be stopped or started, and the current time cannot be set. A CMClock has one primary function, CMClockGetTime(_:), which tells what time it is now. Additionally, the CMSync infrastructure monitors relative drift between CMClocks.

## Topics

### Inspecting a Clock

- [time](coremedia/cmclock/time.md)
- [typeID](coremedia/cmclock/typeid.md)

### Stopping a Clock

- [invalidate()](coremedia/cmclock/invalidate().md)

### Getting the Host Time

- [hostTimeClock](coremedia/cmclock/hosttimeclock.md)

### Getting Time and Devices

- [anchorTime()](coremedia/cmclock/anchortime().md)
- [audioDevice()](coremedia/cmclock/audiodevice().md)
- [setAudioDeviceID(_:)](coremedia/cmclock/setaudiodeviceid(_:).md)
- [setAudioDeviceUID(_:)](coremedia/cmclock/setaudiodeviceuid(_:).md)

### Determining Time Drift

- [mightDrift(relativeTo:)](coremedia/cmclock/mightdrift(relativeto:).md)

### Converting Time

- [convertHostTimeToSystemUnits(_:)](coremedia/cmclock/converthosttimetosystemunits(_:).md)
- [convertSystemUnitsToHostTime(_:)](coremedia/cmclock/convertsystemunitstohosttime(_:).md)

### Constants

- [CMClock.Error](coremedia/cmclock/error.md)

### Initializers

- [init(referencing:)](coremedia/cmclock/init(referencing:).md)

### Type Aliases

- [CMClock.T](coremedia/cmclock/t.md)

### Default Implementations

- [CMSyncProtocol Implementations](coremedia/cmclock/cmsyncprotocol-implementations.md)

## Relationships

### Conforms To

- [CMSyncProtocol](coremedia/cmsyncprotocol.md)
- [Copyable](swift/copyable.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Data Types

- [CMClockOrTimebase](coremedia/cmclockortimebase.md)
- [CMClockGetTypeID()](coremedia/cmclockgettypeid().md)
