MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / getModulationandSpeed

Function getModulationandSpeed

lib/imagewriter/imdimagewriter.cc:20–81  ·  view source on GitHub ↗

22 karakters

Source from the content-addressed store, hash-verified

18 */
19static const char LABEL[] = "IMD archive by fluxengine on"; // 22 karakters
20static uint8_t getModulationandSpeed(
21 int flags, ImdOutputProto::RecordingMode mode)
22{
23 if (flags == 0)
24 {
25 error(
26 "Can't write IMD files with this speed {}, and modulation {}. Did "
27 "you read a real disk?",
28 flags,
29 false);
30 }
31 else
32 {
33 flags = 1000000.0 / flags;
34 }
35
36 if ((flags > 950) and
37 (flags < 1050)) // HD disk 5% discrepency is ok 1000*5% = 50 1 us
38 {
39 /* 500 kbps */
40 if (mode == ImdOutputProto::RECMODE_FM)
41 {
42 return 0;
43 }
44 else
45 {
46 return 3;
47 }
48 }
49 else if ((flags > 1475) and (flags < 1575)) // SD disk
50 {
51 /* 300 kbps*/
52 if (mode == ImdOutputProto::RECMODE_FM)
53 {
54 return 1;
55 }
56 else
57 {
58 return 4;
59 }
60 }
61 else if ((flags > 1900) and (flags < 2100)) // DD disk
62 {
63 /* 250 kbps */
64 if (mode == ImdOutputProto::RECMODE_FM)
65 {
66 return 2;
67 }
68 else
69 {
70 return 5;
71 }
72 }
73 else
74 {
75 error(
76 "IMD: Can't write IMD files with this speed {}, and modulation {}. "
77 "Try another format.",

Callers 1

writeImageMethod · 0.70

Calls 1

errorFunction · 0.85

Tested by

no test coverage detected