1
00:00:01,080 --> 00:00:03,000
Speaker 1: How'd you like to listen to dot net rocks with

2
00:00:03,040 --> 00:00:03,799
no ads?

3
00:00:04,440 --> 00:00:04,799
Speaker 2: Easy?

4
00:00:05,360 --> 00:00:08,560
Speaker 1: Become a patron for just five dollars a month. You

5
00:00:08,599 --> 00:00:11,320
get access to a private RSS feed where all the

6
00:00:11,359 --> 00:00:14,560
shows have no ads. Twenty dollars a month, we'll get

7
00:00:14,599 --> 00:00:17,679
you that and a special dot net Rocks patron mug.

8
00:00:18,160 --> 00:00:34,600
Sign up now at patreon dot dot NetRocks dot com. Hey,

9
00:00:34,679 --> 00:00:38,520
welcome back to dot net rocks. I'm Carl Franklin, an

10
00:00:38,520 --> 00:00:42,960
amateur Campbell and this is episode in nineteen forty six.

11
00:00:43,119 --> 00:00:44,759
Speaker 2: Richard Yay, end of the war.

12
00:00:45,280 --> 00:00:48,880
Speaker 1: Yeah, we're inching closer, aren't we. Let's talk about what

13
00:00:48,920 --> 00:00:52,399
happened in nineteen forty six. The of course, the post

14
00:00:52,399 --> 00:00:55,600
World War II world saw the establishment of the United

15
00:00:55,679 --> 00:00:59,840
Nations after the dissolution of the League of Nations, the

16
00:01:00,039 --> 00:01:07,040
Philippines gained independence, Italy abolished its monarchy, the US Atomic

17
00:01:07,280 --> 00:01:12,079
Energy Commission was established, the Soviet Union rejected a US

18
00:01:12,120 --> 00:01:16,159
proposal for an international agency to control nuclear energy production

19
00:01:16,280 --> 00:01:21,640
and research, and the ENIAC, the first electronic digital computer,

20
00:01:22,120 --> 00:01:24,799
was dedicated. You got anything else to add to that list?

21
00:01:25,200 --> 00:01:29,319
Speaker 2: Well, I mean INIAC was electronic. It had eighteen thousand

22
00:01:29,439 --> 00:01:32,079
vacuum tubes. Yeah, so you know, you can you can

23
00:01:32,120 --> 00:01:34,959
debate how electronic it necessarily was. I was trying to

24
00:01:35,000 --> 00:01:37,280
figure out what the processing rate of it was, because

25
00:01:37,319 --> 00:01:40,799
it could do something like five thousand additions per second

26
00:01:41,439 --> 00:01:44,760
and it did have one hundred kilohertz clock. Wow that

27
00:01:45,000 --> 00:01:46,840
there was one table I found this at It runs

28
00:01:46,840 --> 00:01:50,879
at about five hundred flops or floating floating boat operations

29
00:01:50,920 --> 00:01:51,439
per second.

30
00:01:51,799 --> 00:01:54,439
Speaker 1: So I just remember Uniblab from the Jetsons. Do you

31
00:01:54,439 --> 00:01:54,840
remember that?

32
00:01:55,000 --> 00:01:58,599
Speaker 2: Yeah, a year in a blab And it was of

33
00:01:58,680 --> 00:02:01,920
course originally built to do artillery table calculations, right, that

34
00:02:02,359 --> 00:02:04,840
was three or four years earlier. But by the time

35
00:02:04,879 --> 00:02:08,000
they actually get it built, most protect stuff solved, and

36
00:02:08,039 --> 00:02:11,919
they've shrunk down artillery table calculators enough that they're now

37
00:02:12,000 --> 00:02:15,680
being put inside of battleships. The very first program that

38
00:02:15,719 --> 00:02:20,400
it ran was a Monti Carlo simulation for calculating neutron

39
00:02:20,439 --> 00:02:22,879
propagation in thermonuclear weapons.

40
00:02:23,080 --> 00:02:26,199
Speaker 1: How does Monty Carlo and thermonuclear weapons go together? In

41
00:02:26,240 --> 00:02:28,280
the same sentence, I'm glad you asked.

42
00:02:29,879 --> 00:02:31,919
Speaker 2: A Monty Carlo simulation is an idea that we don't

43
00:02:31,960 --> 00:02:35,280
know all of the variables. We just know some behavior

44
00:02:35,280 --> 00:02:37,560
of some elements. In this particular case, you're talking about

45
00:02:37,560 --> 00:02:42,360
neutron propagations of how neutrons move through certain materials, and

46
00:02:42,479 --> 00:02:46,400
so you're able to run multiple simultaneous calculations. It's too

47
00:02:46,439 --> 00:02:48,439
hard to do by hand. You needed a fast computer,

48
00:02:48,719 --> 00:02:52,080
and at that time, ENIAC was the fast computer that

49
00:02:52,199 --> 00:02:55,039
sort of proved that a Monte Carlo simulation is even possible.

50
00:02:55,199 --> 00:02:58,280
Speaker 1: So they call it a Monti Carlos simulation because it's

51
00:02:58,319 --> 00:02:59,919
related to gambling of some kind.

52
00:03:00,840 --> 00:03:02,919
Speaker 2: Yeah, that was partly at one of the scientists that

53
00:03:03,080 --> 00:03:05,840
have a degenerate uncle that was prone to gambling. They

54
00:03:05,879 --> 00:03:08,240
needed a code name, so it started out as kind

55
00:03:08,280 --> 00:03:11,319
of the code name. Okay, but it is a a

56
00:03:11,360 --> 00:03:15,400
probabilistic heroism calculator, which is kind of the way a

57
00:03:15,400 --> 00:03:18,400
lot of gambling numbers work anyway, So it all kinds

58
00:03:18,400 --> 00:03:21,280
of goes together. There's a randomness factor to this, But

59
00:03:22,039 --> 00:03:26,159
I would point out it did demonstrate that beryllium was

60
00:03:26,680 --> 00:03:29,960
an effective reflector of neutrons at a certain rate, so

61
00:03:30,000 --> 00:03:32,439
they knew how thick to make the linings to be

62
00:03:32,520 --> 00:03:36,680
able to do the second stage explosions like it worked

63
00:03:36,840 --> 00:03:38,919
at bend the path that would take several years for

64
00:03:38,960 --> 00:03:41,159
them to actually build a working thermonucular device and go

65
00:03:41,199 --> 00:03:44,560
from kilotons to megatons. But this was the beginning of it.

66
00:03:44,599 --> 00:03:46,520
An ediac was key to it. Wow, it's good to

67
00:03:46,560 --> 00:03:47,719
know history, kids.

68
00:03:48,039 --> 00:03:51,879
Speaker 1: Yeah, just listen to Uncle Richard and we do geek

69
00:03:51,879 --> 00:03:54,840
outs on these things occasionally once a year around the

70
00:03:54,919 --> 00:03:57,680
end of the year. So if you just search geek

71
00:03:57,719 --> 00:04:00,400
out on our air rocks dot com set, you can

72
00:04:00,400 --> 00:04:04,360
find a whole host of topics. All right, well, let's

73
00:04:04,400 --> 00:04:16,040
get started with better no framework roll the music. So

74
00:04:16,079 --> 00:04:18,800
what I have is a little tool that I wrote

75
00:04:18,920 --> 00:04:23,319
for Blazer. It's a Blazer component called AVN Audio AVN

76
00:04:23,360 --> 00:04:27,639
for app v next that records audio and provides buffers

77
00:04:27,639 --> 00:04:31,040
in real time. So, knowing the topic that we're going

78
00:04:31,120 --> 00:04:33,879
to talk about with l S today, I pulled this up.

79
00:04:34,279 --> 00:04:36,480
This is not audio and video in dot net. This

80
00:04:36,600 --> 00:04:40,959
is Blazer. So it's web based audio. We're actually using

81
00:04:41,279 --> 00:04:46,120
a web based tool right now to record audio and

82
00:04:46,240 --> 00:04:49,279
video in real time. And the reason that it works

83
00:04:49,600 --> 00:04:56,480
is because the browsers now support these standards that make

84
00:04:56,560 --> 00:05:01,120
this stuff possible and finally obtainable for your average JavaScript developer.

85
00:05:02,439 --> 00:05:05,920
And it's really remarkable. Like we're looking at our video

86
00:05:06,000 --> 00:05:10,000
in real time, we're listening to each other in almost

87
00:05:10,040 --> 00:05:12,160
real time. You know, there's a little delay, but you

88
00:05:12,199 --> 00:05:13,040
don't notice it.

89
00:05:13,040 --> 00:05:15,920
Speaker 2: It's close enough, right, that's the key.

90
00:05:15,959 --> 00:05:19,879
Speaker 1: It's not perfect, right, And it's uploading our audio in

91
00:05:19,920 --> 00:05:23,399
the background as we're recording it. And then by the

92
00:05:23,439 --> 00:05:26,600
time we're done, you know, maybe five ten seconds later,

93
00:05:26,720 --> 00:05:29,600
it's there. It's all there in the cloud. So the

94
00:05:29,680 --> 00:05:34,319
technology has really gotten good. And I use this opportunity

95
00:05:34,360 --> 00:05:37,959
to create a component that we'll start recording audio and

96
00:05:38,000 --> 00:05:40,879
then call you back in you know in Blazer and

97
00:05:40,920 --> 00:05:44,160
see sharp were the buffer and you can do whatever

98
00:05:44,160 --> 00:05:46,439
you want with that buffer. You can compress it and

99
00:05:46,560 --> 00:05:49,759
stream it, you can write it to disc all that

100
00:05:49,839 --> 00:05:51,879
kind of stuff. So I thought that would be a

101
00:05:51,879 --> 00:05:56,639
fun little way to start just and it uses well,

102
00:05:56,680 --> 00:06:03,319
it used to use ffm peg, but there's one demo

103
00:06:03,360 --> 00:06:08,040
that does use it. So ffm peg is a command

104
00:06:08,079 --> 00:06:11,480
line tool for doing all kinds of things with audio

105
00:06:11,519 --> 00:06:14,560
and video and it works great and c sharp if

106
00:06:14,560 --> 00:06:20,360
you're using standard in Standard out. Just a great little tool.

107
00:06:20,560 --> 00:06:23,879
Use it all the time anyway, That's what I got Richard,

108
00:06:24,439 --> 00:06:26,600
and who's talking to us today.

109
00:06:26,680 --> 00:06:29,519
Speaker 2: We don't do audio video too often, so I jumped

110
00:06:29,519 --> 00:06:31,720
into the wayback machine. I went back to twenty thirteenth

111
00:06:31,800 --> 00:06:34,600
episode eight point fifty four, when Mark Heath talked about

112
00:06:34,959 --> 00:06:38,160
audio and Windows. Yeah, specifically the project he was working on,

113
00:06:38,160 --> 00:06:43,839
which was an audio in CodePlex code plex. I love

114
00:06:43,879 --> 00:06:45,720
in audio and got it. We got a ton of

115
00:06:45,759 --> 00:06:47,600
comments on the show. I just grabbed one give mely

116
00:06:47,680 --> 00:06:50,560
twelve years ago. This from Jph says, Hey, Carl, what

117
00:06:50,639 --> 00:06:53,360
a great geek out show. I'm sure some of the

118
00:06:53,399 --> 00:06:56,240
discussion took a lot of the listeners, including myself, back

119
00:06:56,279 --> 00:06:59,879
to the SoundBlaster days. Oh yeah, I remember getting my

120
00:07:00,199 --> 00:07:03,279
sound blaster back in the early nineties. I was thinking

121
00:07:03,279 --> 00:07:06,160
how magical it was to record and play wave files

122
00:07:06,480 --> 00:07:10,279
a computer, producing real time sounds. Magic. Yeah, And obviously

123
00:07:10,279 --> 00:07:12,040
we've come a long way since then, and things usually

124
00:07:12,040 --> 00:07:14,240
work pretty well on Windows when you just need a

125
00:07:14,240 --> 00:07:17,560
standard audio playback. There's one thing though, when we all

126
00:07:17,600 --> 00:07:20,920
went from XP or Vista to Win seven and most

127
00:07:20,920 --> 00:07:24,199
people with built in sound cards lost the capability record

128
00:07:24,199 --> 00:07:26,759
exactly what you hear as standard out of the output back,

129
00:07:26,800 --> 00:07:29,720
which it can awesome be useful. There's also an option

130
00:07:29,920 --> 00:07:31,959
to you in the Windows Sound Mixer, but for some

131
00:07:32,000 --> 00:07:34,040
reason we've lost that and it was you know, it

132
00:07:34,079 --> 00:07:36,519
was in there somewhere, but they were messing like how

133
00:07:36,519 --> 00:07:39,519
many different flipping control panels do you need? Right, It's crazy.

134
00:07:39,680 --> 00:07:42,160
Discussion about doing real time audio processing and showing wave

135
00:07:42,160 --> 00:07:44,120
forms of meters during recording reminded me of something that

136
00:07:44,160 --> 00:07:46,160
has in fact only a tangent but appealed to me

137
00:07:46,199 --> 00:07:49,639
as a dev when I was tickering with MIDI controllers. Hey,

138
00:07:49,879 --> 00:07:51,720
and it may be helpful people who don't want to

139
00:07:51,720 --> 00:07:54,519
shallow a lot of cash for MIDI hardware. Touch osc

140
00:07:54,639 --> 00:07:57,600
is an application for touch devices, iOS and Android admittedly

141
00:07:57,680 --> 00:08:01,680
is in twenty thirteen. Right I moved on that lets

142
00:08:01,720 --> 00:08:05,480
you define a rich MIDI control surface with buttons, rotary knobs,

143
00:08:05,480 --> 00:08:08,560
faders and even xypads and other controls, then shows up

144
00:08:08,600 --> 00:08:11,120
as a regular MIDI controller on computer via Wi Fi.

145
00:08:11,759 --> 00:08:14,319
Had great fun hooking up different controls to minifunctions using

146
00:08:14,319 --> 00:08:16,079
your form designer and using it on an iPad as

147
00:08:16,120 --> 00:08:19,519
a control ser geeky audio stuff and computers. I love it.

148
00:08:19,560 --> 00:08:21,600
Speaker 1: And you know, I have a little history with a

149
00:08:21,639 --> 00:08:27,079
sound blaster because at the time the MIDI pack for

150
00:08:28,120 --> 00:08:31,920
the sound Blaster came out company. I worked for Voyetra Technologies.

151
00:08:32,120 --> 00:08:36,519
They had the deal with the sound Blaster to provide

152
00:08:36,519 --> 00:08:41,600
that hardware and the sequencer sequencer plus software, and I

153
00:08:41,759 --> 00:08:46,480
was tasked with making some sample MIDI files that could

154
00:08:46,480 --> 00:08:49,799
be shipped with it. And so when if you got

155
00:08:49,799 --> 00:08:53,080
the sound Blaster MIDI add on you look at those

156
00:08:53,120 --> 00:08:55,000
mini files. Yeah, I wrote those.

157
00:08:55,279 --> 00:08:55,559
Speaker 2: Nice.

158
00:08:55,639 --> 00:08:59,120
Speaker 1: Also, I remember going out to dinner with mister sim

159
00:08:59,399 --> 00:09:03,639
who is the inventor of the sound Blaster, and seeing

160
00:09:03,799 --> 00:09:07,200
actually him at PCXPO I think it was at the

161
00:09:07,200 --> 00:09:12,559
time the Javit Center, and he wanted me to record

162
00:09:12,639 --> 00:09:15,840
re record the files for the Talking Parrot. You remember

163
00:09:15,840 --> 00:09:19,480
the talking parrot Elias right, yeah, yeah, And I never did.

164
00:09:19,720 --> 00:09:20,600
Speaker 2: I was such a jerk.

165
00:09:20,639 --> 00:09:23,120
Speaker 1: I could have done that too, because he wanted, you know,

166
00:09:23,840 --> 00:09:29,120
funnier things than he had responded with the parrot. Basically,

167
00:09:29,159 --> 00:09:32,759
you talk to the parrot and it gives you these crazy, wacky,

168
00:09:33,799 --> 00:09:36,440
high pitched responses.

169
00:09:36,799 --> 00:09:37,360
Speaker 3: Don't touch me.

170
00:09:37,799 --> 00:09:43,039
Speaker 1: Yeah yeah, die q, I think that was one of mine. Anyway,

171
00:09:43,360 --> 00:09:46,399
didn't do it, but it was fun, fun times, fun times.

172
00:09:46,440 --> 00:09:48,720
Speaker 2: So thanks JP for your comment and a copy of

173
00:09:48,799 --> 00:09:50,080
music co buy is on it's way to you, and

174
00:09:50,120 --> 00:09:51,720
if you'd like copy music, go buy. I write a

175
00:09:51,720 --> 00:09:53,799
comment on the website at dot at rocks dot com

176
00:09:53,879 --> 00:09:55,639
or on the facebooks. We publish every show there and

177
00:09:55,639 --> 00:09:57,159
if you comment there, and every ready on the show

178
00:09:57,440 --> 00:09:58,840
was at your copy music, go by.

179
00:09:58,759 --> 00:10:02,000
Speaker 1: And music to code by going strong. We've got track

180
00:10:02,039 --> 00:10:05,200
twenty two now and you can go to music toocode

181
00:10:05,240 --> 00:10:10,120
by dot net, which is a URL rerouter. So HDTPS

182
00:10:10,200 --> 00:10:11,840
isn't going to work. But if you just say music

183
00:10:11,840 --> 00:10:14,240
tocode by dot net, that'll bring you there and you

184
00:10:14,240 --> 00:10:16,080
can get just track twenty two if you want, or

185
00:10:16,120 --> 00:10:19,639
the entire collection in MP three wave or flack format.

186
00:10:20,200 --> 00:10:22,639
So with that, let's bring back to dot net Rocks.

187
00:10:23,360 --> 00:10:27,919
Elias Purinin He is an early innovator in digital event

188
00:10:28,039 --> 00:10:31,879
experiences and the founder of Tractus Events. As both a

189
00:10:31,960 --> 00:10:37,519
programmer and producer, he leverages av over, IP and NDI technology,

190
00:10:37,679 --> 00:10:42,440
which I also love to deliver broadcast quality conferences, trade shows,

191
00:10:42,440 --> 00:10:46,840
and workshops on any budget. Elias personally develops much of

192
00:10:46,879 --> 00:10:50,639
the software his team uses, ensuring every aspect of production

193
00:10:50,799 --> 00:10:54,840
is tightly controlled. His high standards for quality have led

194
00:10:54,879 --> 00:10:58,679
to award winning events, including a collaboration with University of

195
00:10:58,720 --> 00:11:04,159
Waterloost Speed that garnered over fourteen thousand views and earned

196
00:11:04,200 --> 00:11:08,080
a Case Circle of Excellence Award. He is also the

197
00:11:08,120 --> 00:11:12,879
author of Memorable, Profitable Virtual How to run virtual Events

198
00:11:12,919 --> 00:11:17,200
that create meaning, value and lasting connections. Finally, for the

199
00:11:17,240 --> 00:11:20,480
nerd crads. Elias first started with VB dot net one

200
00:11:20,480 --> 00:11:23,000
point one back in two thousand and five, but has

201
00:11:23,039 --> 00:11:25,919
since crossed over the dark side and writes almost everything

202
00:11:25,960 --> 00:11:29,440
in C sharp these days. He used C to write

203
00:11:29,519 --> 00:11:32,840
games for the Game Boy Advance. He programmed a game

204
00:11:32,919 --> 00:11:36,159
for the Atari twenty six hundred in six five h

205
00:11:36,240 --> 00:11:39,240
two assembly in twenty four hours, and loves writing a

206
00:11:39,279 --> 00:11:42,679
great select Star from a sequel server database.

207
00:11:44,480 --> 00:11:48,799
Speaker 2: How to make your DBAs angry. That's right, select Star.

208
00:11:49,440 --> 00:11:51,240
Speaker 1: Welcome back, Elias, Thank you gentlemen.

209
00:11:51,279 --> 00:11:53,559
Speaker 3: It's awesome to be back. I cannot wait to talk

210
00:11:53,679 --> 00:11:55,720
P and voke and NDI and.

211
00:11:55,679 --> 00:11:59,399
Speaker 1: Every day day over ip P and voke Man, we

212
00:11:59,399 --> 00:12:03,480
were talking about one of the earliest components or ds

213
00:12:03,519 --> 00:12:06,759
that I wrote for dot net was in vbnet and

214
00:12:06,799 --> 00:12:10,000
I used P and voke to do to simplify access to.

215
00:12:09,960 --> 00:12:12,799
Speaker 3: MIDI right and so like back then, we didn't have

216
00:12:12,799 --> 00:12:14,639
any audio, we didn't have any of those other tools,

217
00:12:14,639 --> 00:12:19,360
Like you had to go into what was it the MMAPI, right, MULTIMEDIAPI.

218
00:12:18,679 --> 00:12:19,879
Speaker 1: To do that MULTIMEDIAPI.

219
00:12:20,039 --> 00:12:24,320
Speaker 3: Yeah, yeah, that was. But what's stunning is how little

220
00:12:24,360 --> 00:12:27,039
the p and voke APIs have changed in dot Net,

221
00:12:27,080 --> 00:12:29,879
Like how you actually write that code. Yeah, and how

222
00:12:30,480 --> 00:12:33,519
relevant it is like twenty plus years later.

223
00:12:33,559 --> 00:12:36,519
Speaker 1: And just to back up, p invoke stands for platform invoke.

224
00:12:36,759 --> 00:12:38,519
So this is a way that you can use whatever

225
00:12:38,559 --> 00:12:43,320
managed language that you want to make API calls to

226
00:12:43,399 --> 00:12:47,360
the unmanaged platform APIs that you're running on.

227
00:12:47,639 --> 00:12:52,120
Speaker 3: Right, So imagine you've got a unmanaged DLL of some

228
00:12:52,279 --> 00:12:55,080
sort and it does something for you, and you want

229
00:12:55,120 --> 00:12:58,440
to use the result of a function call from that

230
00:12:58,600 --> 00:13:00,759
DLL in you want to as a result of that

231
00:13:00,799 --> 00:13:02,799
in C sharp or just dot net in general. You

232
00:13:02,799 --> 00:13:06,000
could do that with VBNT two. So you would write

233
00:13:06,039 --> 00:13:10,519
a special function wrapper, you know, especially defined function like

234
00:13:10,679 --> 00:13:14,159
public extern void, whatever, the signature name is, put in

235
00:13:14,159 --> 00:13:19,440
the right parameters, decorate it with the correct attribute, and maam,

236
00:13:19,480 --> 00:13:21,559
now you can call into As long as that DLL

237
00:13:21,559 --> 00:13:24,799
can be found by your process, you can call into

238
00:13:24,799 --> 00:13:25,759
that DLL.

239
00:13:25,480 --> 00:13:29,559
Speaker 1: And your parameter types are absolutely accurate. If they're not

240
00:13:29,879 --> 00:13:32,080
all things, all sorts of weird things will happen.

241
00:13:32,720 --> 00:13:35,360
Speaker 3: Oh boy, how do you well? Lots of weird things happen.

242
00:13:35,440 --> 00:13:38,080
Speaker 1: Hey, your compiler won't necessarily know about it ahead of time,

243
00:13:38,080 --> 00:13:38,320
will it?

244
00:13:38,559 --> 00:13:42,480
Speaker 3: No, not necessarily. And sometimes the runtime errors that you'll get,

245
00:13:42,600 --> 00:13:44,279
you know, you'll just crash out. You won't even get

246
00:13:44,320 --> 00:13:48,519
an exception, and things will just fall over that said

247
00:13:48,559 --> 00:13:51,240
the compiler, even though the compiler may not catch it.

248
00:13:51,279 --> 00:13:53,720
There have been instances, and we'll talk about that. We'll

249
00:13:53,720 --> 00:13:57,960
talk about specifics later, especially around union types where at

250
00:13:58,039 --> 00:14:01,559
runtime you'll get very specific pacific errors to say, hey,

251
00:14:01,600 --> 00:14:05,360
your structs aren't defined properly. Yeah, but that's we'll talk

252
00:14:05,399 --> 00:14:07,720
about kind of the nuts and bolts there later.

253
00:14:07,919 --> 00:14:11,039
Speaker 2: Can we talk about the wisdom of using a garbage

254
00:14:11,039 --> 00:14:13,799
collected language in a real time operation like an event?

255
00:14:14,120 --> 00:14:14,840
Speaker 3: Yeah? For sure.

256
00:14:15,399 --> 00:14:17,720
Speaker 2: Shouldn't this all be written in C plus plus? Like?

257
00:14:18,159 --> 00:14:20,159
Why are you in the p and voke land? Why

258
00:14:20,200 --> 00:14:21,600
aren't you staying closer to the metal?

259
00:14:21,799 --> 00:14:23,960
Speaker 3: So I thought about this. I thought about this a

260
00:14:23,960 --> 00:14:27,080
lot because the background behind what I've been doing for

261
00:14:27,080 --> 00:14:30,120
the last probably two years has been real time audio

262
00:14:30,159 --> 00:14:33,960
and video, specifically using a technology called NDI. NDI short

263
00:14:33,960 --> 00:14:36,519
for Network Device Interface. Long and short of it is,

264
00:14:36,600 --> 00:14:38,799
it's a way to send real time audio and video

265
00:14:39,000 --> 00:14:42,399
over a LAMB. And when I'm talking real time, we're

266
00:14:42,399 --> 00:14:44,840
talking latency of a frame or less.

267
00:14:44,879 --> 00:14:47,320
Speaker 1: In some cases it can be Yeah, you have to

268
00:14:47,360 --> 00:14:50,320
have a very fast network. But there's oh boy, are

269
00:14:50,360 --> 00:14:53,000
there a lot of variables on that one. So it's

270
00:14:53,080 --> 00:14:55,919
the network, The knicks have to be configured, good drivers,

271
00:14:56,360 --> 00:14:58,200
you know, there's a lot that goes into it.

272
00:14:58,240 --> 00:15:00,480
Speaker 3: And I've done a lot of research on it. But

273
00:15:00,679 --> 00:15:04,879
the upshot is the lowest theoretical latency that I've read

274
00:15:05,039 --> 00:15:07,639
is down in the number of scan lines. Wow, so

275
00:15:07,759 --> 00:15:09,279
less than a frame of latency you get down to

276
00:15:09,320 --> 00:15:09,919
scan lines.

277
00:15:10,039 --> 00:15:12,480
Speaker 2: That's great. Well, especially when you're talking about four K

278
00:15:12,840 --> 00:15:17,320
where you've got what twenty one sixty scan lines per frame.

279
00:15:17,840 --> 00:15:20,639
Speaker 3: Yeah, so it's I mean there's a lot of asterisks

280
00:15:20,679 --> 00:15:24,200
to achieve that low latency, right, But I mean, if.

281
00:15:24,120 --> 00:15:29,519
Speaker 1: You're doing four K over a one hundred megabit network

282
00:15:29,799 --> 00:15:32,440
is not going to get You're not do net ain't

283
00:15:32,480 --> 00:15:33,799
going to work.

284
00:15:33,840 --> 00:15:36,159
Speaker 2: Ivan gig is humming at the limit at that point.

285
00:15:36,360 --> 00:15:39,000
Speaker 3: Yeah, yeah, depending on your encoder, depending on the device.

286
00:15:39,120 --> 00:15:42,559
Like you can cram about four full bandwidth NDI sources

287
00:15:42,600 --> 00:15:45,240
onto a gig connection. Probably don't want to do that,

288
00:15:45,320 --> 00:15:45,840
but you can.

289
00:15:46,080 --> 00:15:49,480
Speaker 2: You can. Yeah, yeah, because network storms are still a thing.

290
00:15:49,519 --> 00:15:51,559
We usually don't hit them because we have enough bandwidth

291
00:15:51,600 --> 00:15:53,879
we don't think about it. But once you get upwards

292
00:15:53,879 --> 00:15:56,159
at eighty percent or so and start getting collisions, it

293
00:15:56,200 --> 00:15:58,639
gets way where it falls off a clip fast.

294
00:15:58,759 --> 00:15:59,240
Speaker 3: Oh yeah.

295
00:15:59,279 --> 00:16:04,000
Speaker 1: So, and is a spec that is created by a company, right,

296
00:16:04,039 --> 00:16:07,960
and they give you the NDI tools that you can use, right,

297
00:16:08,000 --> 00:16:09,600
Can you talk a little bit about that, yeah?

298
00:16:09,679 --> 00:16:13,559
Speaker 3: Sure. So NDI was originally created by Newtech who created

299
00:16:13,600 --> 00:16:16,960
the tricasters and going even back even further the Amiga

300
00:16:17,080 --> 00:16:20,519
video toasters right, right, And how NDI evolved was they

301
00:16:20,600 --> 00:16:23,080
wanted to find a way to bring in remote camera

302
00:16:23,159 --> 00:16:26,720
sources or remote screen share sources as video sources over

303
00:16:26,759 --> 00:16:28,919
a network. I think the original term for it was

304
00:16:28,960 --> 00:16:33,120
ivgay and then it's kind of grown from there. Like

305
00:16:33,919 --> 00:16:36,039
behind me, I've got a whole bunch of cameras. They're

306
00:16:36,080 --> 00:16:39,480
all NDII cameras. There's the NDI tools, which is just

307
00:16:39,519 --> 00:16:42,120
software tools that you can use to have a virtual

308
00:16:42,120 --> 00:16:45,159
webcam to send out test patterns to preview your NDI

309
00:16:45,279 --> 00:16:49,919
sources on your network. And then there's the actual hardware itself,

310
00:16:50,039 --> 00:16:53,840
right like cameras, there's some audio gear that's coming out,

311
00:16:54,320 --> 00:16:56,799
converters that will take an NDII signal and turn it

312
00:16:56,840 --> 00:17:01,519
into SDI or HDMI many three and four letter acronyms

313
00:17:01,519 --> 00:17:05,519
around this world. So the idea behind that is instead

314
00:17:05,519 --> 00:17:09,480
of running physical copper cables, SDI or HDMI cables that

315
00:17:09,519 --> 00:17:11,880
carry audio and video, and then you have another cable

316
00:17:11,960 --> 00:17:14,720
for doing control and then maybe another cable for power.

317
00:17:15,799 --> 00:17:18,640
If you've say, got an NDI camera and it's power

318
00:17:18,680 --> 00:17:23,720
over Ethernet, I'm now sending audio, video, control, and power

319
00:17:23,880 --> 00:17:24,880
over one cable.

320
00:17:24,960 --> 00:17:26,599
Speaker 2: Yeah right, and it's an Ethernet cable.

321
00:17:26,759 --> 00:17:28,759
Speaker 3: It's an Ethernet cable. So like if I destroy a

322
00:17:28,759 --> 00:17:30,960
fifty foot Ethernet cable, okay, so what I go to

323
00:17:31,000 --> 00:17:32,680
Amazon and buy a new one twenty bucks?

324
00:17:32,720 --> 00:17:34,160
Speaker 2: Yeah yeah, yeah, if.

325
00:17:34,000 --> 00:17:36,759
Speaker 3: I destroy a fifty foot SDI cable, someone's getting in trouble.

326
00:17:36,839 --> 00:17:41,559
Speaker 2: Everybody's sad. Yeah, but I mean tricasting the day was

327
00:17:41,680 --> 00:17:45,599
the device. The market's blown wide open now with atems

328
00:17:46,440 --> 00:17:48,960
roads stuff and so forth. Although I think the real

329
00:17:49,039 --> 00:17:51,759
thing that I noticed was one day everyone said, you know,

330
00:17:52,519 --> 00:17:54,960
maybe it's okay to drop a frame now again, Like

331
00:17:55,240 --> 00:17:59,319
SDI was so strict you needed those really good and

332
00:17:59,400 --> 00:18:02,119
expensive cables and they never dropped a frame Like that

333
00:18:02,200 --> 00:18:04,799
was the whole claim to fame, and HDMI was just

334
00:18:05,039 --> 00:18:08,319
nowhere near that rigorous. And I remember when the first

335
00:18:08,400 --> 00:18:11,640
ATM mini pros came along in the minis and you're like, yeah, no,

336
00:18:11,759 --> 00:18:14,720
occasionally we'll throw a frameway to maintain SINC and live

337
00:18:14,759 --> 00:18:17,279
with it. It's like, but we're going over the internet.

338
00:18:17,359 --> 00:18:19,920
It's not that reliable anyway, what do we care?

339
00:18:20,119 --> 00:18:24,440
Speaker 1: The TriCaster still is like the Mac daddy of all things, right,

340
00:18:24,519 --> 00:18:26,119
it's essentially a Windows PC.

341
00:18:26,440 --> 00:18:28,559
Speaker 2: It's a with a with a console on it.

342
00:18:29,079 --> 00:18:32,920
Speaker 1: With the TriCaster software yeah, with the console yeah, and

343
00:18:33,039 --> 00:18:36,480
all sorts of consoles that you can control it with.

344
00:18:37,039 --> 00:18:39,240
And it's expensive. Yeah, you know, let's face it.

345
00:18:39,400 --> 00:18:42,160
Speaker 3: Yeah, it's a it's an amazing product. It's expensive. The

346
00:18:42,160 --> 00:18:44,000
same compan so the company that made it, New Tech,

347
00:18:44,000 --> 00:18:48,039
they eventually got acquired that's now vis RT. VISRT split

348
00:18:48,519 --> 00:18:52,400
this NDI project off into its own entity. So NDI

349
00:18:52,480 --> 00:18:55,480
exists as a company as well, and so you can

350
00:18:55,599 --> 00:18:57,519
you as a developer, can go out and get the

351
00:18:57,519 --> 00:19:01,359
basic SDK, integrate that into your application, and then you

352
00:19:01,400 --> 00:19:03,880
can also get the Advanced SDK, which gives you a

353
00:19:03,920 --> 00:19:07,279
lot lower level control over how the whole how your

354
00:19:07,359 --> 00:19:08,680
NDI application behaved.

355
00:19:08,720 --> 00:19:12,519
Speaker 1: Now there's a lower cost alternative to the TriCaster that

356
00:19:12,599 --> 00:19:14,799
I know you use and because we talked about it

357
00:19:14,839 --> 00:19:16,720
before we started, and I use it as well that

358
00:19:16,759 --> 00:19:19,319
I want to talk about. And that's v mix, Yes,

359
00:19:20,039 --> 00:19:23,440
vmix dot com. And here's what I know about VMX.

360
00:19:23,880 --> 00:19:27,079
It's a WPF app written in vb net. Yes, how

361
00:19:27,119 --> 00:19:29,559
cool is that? Yeah, it's it's super cool.

362
00:19:30,000 --> 00:19:32,519
Speaker 3: Like to be clear, they've got unmanaged stuff going on

363
00:19:32,599 --> 00:19:35,799
as well, like obviously just to interact, but it is

364
00:19:35,880 --> 00:19:38,279
written in vb net. It is super super cool.

365
00:19:38,200 --> 00:19:42,000
Speaker 1: Yeah, and rock solid. Like these guys are in Australia

366
00:19:42,640 --> 00:19:45,279
and you can have I don't know they have these

367
00:19:45,319 --> 00:19:48,240
callers right, and you can buy it based on how

368
00:19:48,279 --> 00:19:52,559
many input callers you can have remotely and the caller

369
00:19:53,160 --> 00:19:55,359
API think that max is out at eight?

370
00:19:55,519 --> 00:19:58,720
Speaker 3: I think right, yeah, v mix call I think it's eight, yeah, v.

371
00:19:58,799 --> 00:20:01,759
Speaker 1: Mix Call and so you can give out these you know,

372
00:20:02,240 --> 00:20:04,279
URLs to everybody who you want to call, and then

373
00:20:04,319 --> 00:20:07,920
you have this dashboard where you can you know, select

374
00:20:08,000 --> 00:20:10,279
the It's very much kind of it's kind of like

375
00:20:10,359 --> 00:20:14,680
if you've used you know, what's the OBS, right, OBS studio,

376
00:20:15,079 --> 00:20:18,440
but on steroids. That's the way I look at it.

377
00:20:18,440 --> 00:20:21,400
Speaker 3: It's kind of like OBS went to college. Yeah, nice, Yeah,

378
00:20:21,440 --> 00:20:24,319
it's and like it's for us. We also use v

379
00:20:24,359 --> 00:20:26,759
mix to do like when we're doing our hybrid shows,

380
00:20:26,960 --> 00:20:29,599
like we'll have we'll have one single v mix rig

381
00:20:29,640 --> 00:20:31,839
that's pushing out the local feed, like what's going to

382
00:20:31,839 --> 00:20:34,680
the local projectors. We'll have one that's pushing out the

383
00:20:34,759 --> 00:20:37,160
virtual feed to English listeners. We'll have one that's pushing

384
00:20:37,200 --> 00:20:40,039
out to French listeners, and like all from one application,

385
00:20:40,160 --> 00:20:42,160
right yeah, And this was the sort of stuff that

386
00:20:42,200 --> 00:20:44,279
you used to have to get you know, the big

387
00:20:44,319 --> 00:20:47,400
broadcast consoles to do, right sure, And it's like a

388
00:20:47,400 --> 00:20:49,480
fifty dollars license and you can do the same thing

389
00:20:49,559 --> 00:20:52,240
that you know, cost hundreds of thousands of dollars back

390
00:20:52,279 --> 00:20:53,640
in the day, and it works.

391
00:20:53,880 --> 00:20:57,200
Speaker 1: And as a developer, it's even cooler because they've exposed

392
00:20:57,200 --> 00:21:00,759
an API that you can access just through a low URL.

393
00:21:01,519 --> 00:21:03,599
So if you can write a c sharp app that

394
00:21:04,599 --> 00:21:08,720
you know uses an HDP client with a local URL,

395
00:21:08,960 --> 00:21:11,319
you form that URL with the commands and data that

396
00:21:11,359 --> 00:21:14,119
you want, and you can pretty much do everything that

397
00:21:14,160 --> 00:21:17,880
the app does programmatically from your own interface.

398
00:21:18,400 --> 00:21:20,880
Speaker 3: Yeah, about eighty percent of it, but yeah, it's pretty

399
00:21:20,920 --> 00:21:23,000
pretty close. We use it. We use it a fair

400
00:21:23,039 --> 00:21:23,920
We use a fair amount.

401
00:21:23,960 --> 00:21:26,440
Speaker 2: The trick, of course, is getting all the data into

402
00:21:26,480 --> 00:21:29,599
your machine. But if you're going all Ethernet, if it's

403
00:21:29,640 --> 00:21:31,720
all POE and stuff, then you don't need a lot

404
00:21:31,720 --> 00:21:33,440
of hardware on your machine to make this work. Yeah,

405
00:21:33,599 --> 00:21:34,559
avast of computer.

406
00:21:34,680 --> 00:21:39,359
Speaker 1: I've done multiple events with v mix and I've done

407
00:21:39,480 --> 00:21:42,799
I did one from my home, and I did one

408
00:21:43,279 --> 00:21:46,839
down in Brooklyn at a at an event down there

409
00:21:47,640 --> 00:21:50,079
that was just amazing. And that was the probably the

410
00:21:50,119 --> 00:21:52,319
hardest event I ever had to do because there was

411
00:21:52,400 --> 00:21:55,480
so many cues and so many buttons and so many

412
00:21:55,480 --> 00:21:59,200
things to think about. It can get overwhelming. And I

413
00:21:59,200 --> 00:22:02,880
think that's why if you get to that level, people

414
00:22:02,920 --> 00:22:05,200
I know would move up to the TriCaster.

415
00:22:05,000 --> 00:22:07,160
Speaker 3: Or you're loading your desk up with a whole whack

416
00:22:07,200 --> 00:22:09,640
of stream decks and using bit Focus Companion.

417
00:22:09,839 --> 00:22:10,240
Speaker 2: There you go.

418
00:22:10,440 --> 00:22:11,559
Speaker 1: That's talk about that.

419
00:22:11,960 --> 00:22:14,359
Speaker 3: So I've got on my desk, I've got three stream

420
00:22:14,400 --> 00:22:18,559
Deck XLS plus along with A plus and those are

421
00:22:18,599 --> 00:22:21,160
all being used to control you know, which presenter goes

422
00:22:21,160 --> 00:22:24,359
into which box on screen, which layout we've got, you know,

423
00:22:24,440 --> 00:22:28,880
transitioning doing takes muting music on muting like it does

424
00:22:28,920 --> 00:22:29,960
our whole show automation.

425
00:22:30,079 --> 00:22:32,279
Speaker 1: So stream Deck is a hardware device with a bunch

426
00:22:32,319 --> 00:22:34,920
of buttons on it that are actually you can load

427
00:22:35,000 --> 00:22:39,039
up with images so in text, so you customize it

428
00:22:39,200 --> 00:22:41,640
for what you want to do on your particular event

429
00:22:41,839 --> 00:22:44,799
or stream or whatever. And as Elia said, you just

430
00:22:44,839 --> 00:22:46,039
pushed the buttons at the right time.

431
00:22:46,119 --> 00:22:47,799
Speaker 2: This is the Elgado hardware. I Gato.

432
00:22:47,920 --> 00:22:49,920
Speaker 3: This is the Algato one, but you can pair it

433
00:22:49,960 --> 00:22:52,480
with a piece of software called Companion. It's made by

434
00:22:52,480 --> 00:22:55,640
Bitfocus and it's like if you thought the Algato software

435
00:22:55,720 --> 00:22:59,599
was awesome. The bit Focused Companion also allows you to

436
00:22:59,640 --> 00:23:02,960
do stuff like I'm going to dynamically update the text

437
00:23:03,039 --> 00:23:06,599
on a bunch of my buttons depending on if I'm recording.

438
00:23:06,799 --> 00:23:09,640
Most common use case I have for that is if

439
00:23:10,440 --> 00:23:12,960
vmex is not recording, I've got a button that is

440
00:23:13,039 --> 00:23:16,279
blinking red at me, not recording, not recording, not recording MM.

441
00:23:16,680 --> 00:23:20,279
That has saved me more than on so many.

442
00:23:20,039 --> 00:23:22,319
Speaker 2: Times, because, yeah, the companion also is basically just a

443
00:23:22,359 --> 00:23:24,960
macro programmer. Whatever you want that button to do in

444
00:23:25,079 --> 00:23:26,960
virtually any other app, it'll do it.

445
00:23:27,079 --> 00:23:27,759
Speaker 3: Yeah exactly.

446
00:23:27,920 --> 00:23:28,359
Speaker 2: Yeah.

447
00:23:28,519 --> 00:23:30,480
Speaker 1: You know, the definition of a genius in the twenty

448
00:23:30,480 --> 00:23:32,880
twenties is, right, someone who can push the right button

449
00:23:32,880 --> 00:23:35,640
at the right time. Oh, yes, to think about it

450
00:23:35,720 --> 00:23:36,759
all comes down to that.

451
00:23:36,759 --> 00:23:38,240
Speaker 3: It's doing your thinking ahead of time.

452
00:23:38,480 --> 00:23:39,480
Speaker 2: Yeah, exactly.

453
00:23:39,720 --> 00:23:44,839
Speaker 1: So when we're talking about audio and video and programming

454
00:23:44,839 --> 00:23:48,720
that with dot net, are you talking about NDI with

455
00:23:48,839 --> 00:23:52,519
C sharp? Is there an NDIAPI for c sharp?

456
00:23:52,680 --> 00:23:58,279
Speaker 3: So originally there was just the CAPI for NDI, but

457
00:23:59,119 --> 00:24:01,480
with the magic in vogue again, if you get the

458
00:24:01,519 --> 00:24:05,599
signatures right, you can basically take your header, your cheader,

459
00:24:05,640 --> 00:24:08,920
translate that into you know, your public extern, void calls

460
00:24:09,000 --> 00:24:12,119
or public extern whatever your struck name is right, and

461
00:24:12,359 --> 00:24:15,880
call into that c API. And as long as you

462
00:24:15,960 --> 00:24:18,240
do everything, as long as you decorate everything correctly, it

463
00:24:18,359 --> 00:24:20,400
all just works. And a lot of times even if

464
00:24:20,440 --> 00:24:22,759
you don't, the marshaler will be there to kind of

465
00:24:22,759 --> 00:24:26,319
save your bake and do things correctly for you. Strings

466
00:24:26,440 --> 00:24:28,599
especially is where things get really weird.

467
00:24:29,039 --> 00:24:31,400
Speaker 1: So you know a questions coming next, Yes, have you

468
00:24:31,839 --> 00:24:36,960
ALISP created a dot Net rapper for the NDI API.

469
00:24:37,160 --> 00:24:39,640
Speaker 3: So I created a dot Net rapper for the Advanced SDK,

470
00:24:39,960 --> 00:24:43,559
and I improved on the rapper that NDI themselves had

471
00:24:43,559 --> 00:24:47,720
originally released to make that portable too. They originally released

472
00:24:47,720 --> 00:24:49,640
it for just the dot net framework, and I ported

473
00:24:49,640 --> 00:24:51,720
that to dot net at the time dot net core

474
00:24:51,799 --> 00:24:54,319
and now just dot Net seven plus. Yeah.

475
00:24:54,359 --> 00:24:55,519
Speaker 2: Wow cool.

476
00:24:56,079 --> 00:24:58,559
Speaker 3: But here's the magic of that rapper though, And this

477
00:24:58,640 --> 00:25:00,599
is where p and voke really starts get powerful in

478
00:25:00,640 --> 00:25:03,680
the modern era of dot net, because when you think

479
00:25:03,680 --> 00:25:07,720
about it, dot Net originally was Windows only, right, And then,

480
00:25:08,480 --> 00:25:10,720
you know, Richard, I would be remiss if I didn't

481
00:25:10,759 --> 00:25:12,640
mention that the only reason that we have the portable

482
00:25:12,640 --> 00:25:14,400
CLR today, and we have a lot of what we

483
00:25:14,440 --> 00:25:17,319
have today is because of all the effort they made

484
00:25:17,680 --> 00:25:21,440
to make dot Net run in SQL server, right, right,

485
00:25:21,839 --> 00:25:23,440
there was that huge effort. What was that like two

486
00:25:23,480 --> 00:25:24,119
thousand and five?

487
00:25:24,519 --> 00:25:26,400
Speaker 2: Yeah, yeah, well delivered in two thousand and five, but

488
00:25:26,440 --> 00:25:28,160
it had been working on since two thousand and three

489
00:25:28,440 --> 00:25:28,920
Net two.

490
00:25:29,440 --> 00:25:31,119
Speaker 3: Right, that was dot Net two O and all the

491
00:25:31,119 --> 00:25:33,799
magic that we got during dot Net two O. So

492
00:25:34,640 --> 00:25:38,079
that work. So now that we have this cross platform

493
00:25:38,200 --> 00:25:41,160
dot Net library, you think about we have all of

494
00:25:41,160 --> 00:25:45,480
these native libraries across all these different platforms. NDI itself

495
00:25:46,200 --> 00:25:50,279
it has an SDK available for Windows, for Mac, for Linux,

496
00:25:51,000 --> 00:25:53,319
and then on top of that, for Linux we have

497
00:25:53,880 --> 00:25:57,039
X eighty six sixty four and we have ARMS sixty four,

498
00:25:58,160 --> 00:26:00,480
and then on Mac we also have eighty six to

499
00:26:00,519 --> 00:26:03,000
sixty four and ARM sixty four as well. Dot Net

500
00:26:03,039 --> 00:26:04,039
also targets.

501
00:26:03,720 --> 00:26:05,480
Speaker 1: All those platforms, right, That's right.

502
00:26:05,640 --> 00:26:07,240
Speaker 3: So I can take my dot Net app, I can

503
00:26:07,279 --> 00:26:09,759
compile it on all these platforms and it's going to

504
00:26:09,839 --> 00:26:12,799
run and not just that, but it's going to run

505
00:26:13,359 --> 00:26:16,119
more or less the same way across all the platforms

506
00:26:16,160 --> 00:26:17,440
because the same source code.

507
00:26:17,440 --> 00:26:19,200
Speaker 2: I think you just made your argument for why I'm

508
00:26:19,200 --> 00:26:21,359
writing this is cea Sharp and said at C plus plus.

509
00:26:21,680 --> 00:26:24,480
Speaker 3: Well, so philosophically, I was thinking about this before we

510
00:26:24,519 --> 00:26:26,759
got on. I was like, Okay, well, why are we

511
00:26:27,160 --> 00:26:29,519
if we're going to be calling into native libraries anyway,

512
00:26:29,799 --> 00:26:32,119
why are we even thinking about C sharp? Why is

513
00:26:32,160 --> 00:26:35,920
that even entering our thought process. When you think about it,

514
00:26:36,400 --> 00:26:40,119
there's only a small percentage of the operations that I'm

515
00:26:40,119 --> 00:26:43,759
doing that I really really need that low level raw speed.

516
00:26:44,759 --> 00:26:47,920
And I would even argue that whatever the dot net

517
00:26:47,960 --> 00:26:51,759
compiler does in the background, especially for talking about ahead

518
00:26:51,759 --> 00:26:56,200
of time compilation, is probably going to write faster, more optimized,

519
00:26:56,200 --> 00:26:59,000
and better code than you can by hand, unless you're

520
00:26:59,039 --> 00:27:01,240
really talking about assembly. In that case, that's a whole

521
00:27:01,279 --> 00:27:02,440
other special world.

522
00:27:02,519 --> 00:27:03,319
Speaker 1: Who's going to do that?

523
00:27:03,400 --> 00:27:05,680
Speaker 2: Then you got chromium twit tweezers out and you're stacking

524
00:27:05,680 --> 00:27:06,799
your own electrons and that's it.

525
00:27:07,200 --> 00:27:11,559
Speaker 3: Oh yeah, exactly that. I mean you start a button. Yeah,

526
00:27:11,640 --> 00:27:15,319
yeah exactly, So like you can you can go do

527
00:27:15,480 --> 00:27:17,920
so we could write the whole application and say CE

528
00:27:18,000 --> 00:27:20,359
or C plus plus. But it's like I don't need

529
00:27:20,440 --> 00:27:23,200
that low level control all the time.

530
00:27:23,119 --> 00:27:24,880
Speaker 2: And you don't want to pay the price of using

531
00:27:24,880 --> 00:27:26,759
that low level language all the time.

532
00:27:27,000 --> 00:27:29,799
Speaker 3: Yeah, and there's a big price involved. Yeah, you know,

533
00:27:29,839 --> 00:27:32,240
I don't get automatic garbage collection. I don't get you know,

534
00:27:32,319 --> 00:27:34,079
I have to think about reference counting. I have to

535
00:27:34,079 --> 00:27:37,519
think about okay this because like, yes, there's type checking,

536
00:27:37,799 --> 00:27:40,480
but there is nothing stopping me from casting one pointer

537
00:27:40,599 --> 00:27:42,759
type to another in de referencing garbage.

538
00:27:43,039 --> 00:27:45,160
Speaker 2: Sure, you know. At the same time, it's like, does

539
00:27:45,160 --> 00:27:48,720
a GC bonk here client? Like, I haven't thought about

540
00:27:48,720 --> 00:27:53,559
a bonked client by our garbage collection in a decade, easy, right,

541
00:27:53,759 --> 00:27:56,440
Like because things have been so fast and it just

542
00:27:56,480 --> 00:27:59,799
stopped being an issue, like noticing the garbage that the

543
00:27:59,799 --> 00:28:02,200
guar coelector was running is a two thousand and five thing,

544
00:28:02,240 --> 00:28:03,559
not a twenty twenty five thing.

545
00:28:03,799 --> 00:28:05,960
Speaker 3: Sure, and there's ways to mitigate that too, if you're

546
00:28:05,960 --> 00:28:08,640
smart about memory management, right, you know you don't You

547
00:28:08,680 --> 00:28:10,960
don't have to worry so much about that these days.

548
00:28:11,039 --> 00:28:13,559
Speaker 2: Yeah, rule number one have more memory.

549
00:28:13,640 --> 00:28:19,079
Speaker 1: Yes, So I was thinking about this. You know, Let's

550
00:28:19,079 --> 00:28:22,599
say we have written our p and voke stuff for

551
00:28:22,640 --> 00:28:24,599
Windows and we want to run it on the Mac.

552
00:28:25,440 --> 00:28:28,559
If you're doing a what is it, you know, a

553
00:28:28,640 --> 00:28:32,599
MAUI app that can run on the Mac. Right, Those

554
00:28:34,160 --> 00:28:40,079
P and voke C sharp extern method declarations from what

555
00:28:40,200 --> 00:28:43,559
I remember, include the name of the library that you

556
00:28:43,599 --> 00:28:47,599
need to call into, like by name Windows there dot DLL.

557
00:28:47,640 --> 00:28:49,119
But what are they on the Mac? Do you have

558
00:28:49,160 --> 00:28:51,160
to change those on each platform?

559
00:28:51,359 --> 00:28:57,400
Speaker 3: So if the marsh the p and VOKE libraries. They

560
00:28:57,960 --> 00:29:03,279
provide a mechanism that instructions dot net how to look

561
00:29:03,359 --> 00:29:06,960
up that DLL or how to look out that dynamic library.

562
00:29:07,319 --> 00:29:10,720
So on Windows, Mac and Linux, you can just generically

563
00:29:10,759 --> 00:29:14,240
say we're dealing with that dynamic link library. The file

564
00:29:14,319 --> 00:29:17,200
name is different, but the concept is the same. This

565
00:29:17,359 --> 00:29:20,119
is a library. It contains some sort of unmanaged code,

566
00:29:20,119 --> 00:29:21,400
and I want to call into it.

567
00:29:21,559 --> 00:29:24,319
Speaker 1: Great, So you don't you have one codebase and it

568
00:29:24,400 --> 00:29:28,000
literally goes from platform to platform without modification. You don't

569
00:29:28,039 --> 00:29:30,920
have any pragmant statements for the platform that you're on.

570
00:29:31,079 --> 00:29:32,960
Speaker 3: See that's and that's the other thing is like if

571
00:29:33,000 --> 00:29:35,680
you think, I think about doing the code portability stuff

572
00:29:35,680 --> 00:29:38,960
back in the WPF silver Light days. So like back

573
00:29:39,000 --> 00:29:41,559
when I was in university, one of my one of

574
00:29:41,599 --> 00:29:44,200
my co op placements was to write was with a

575
00:29:44,400 --> 00:29:48,319
broadcaster and I had to write a timeline control for

576
00:29:48,400 --> 00:29:51,599
a non linear editor like you would see in Adobe

577
00:29:51,720 --> 00:29:54,319
Premiere or after Effects or something like that. Right, But

578
00:29:54,440 --> 00:29:57,359
the use case was this needed to be cross platform

579
00:29:57,400 --> 00:30:00,160
for both WPF and silver Light and had to be

580
00:30:00,200 --> 00:30:01,039
the same code base.

581
00:30:01,920 --> 00:30:05,319
Speaker 2: And so to make the portable class libraries at the time.

582
00:30:05,440 --> 00:30:09,319
Speaker 3: Yeah, this was Yeah, that was PCL, right, so which

583
00:30:09,359 --> 00:30:13,240
they moved away from, right, like, oh yeahcls have been retired. Yeah, PCL.

584
00:30:14,079 --> 00:30:16,079
Because we did PCL, that gave us a baby step

585
00:30:16,119 --> 00:30:19,960
to dot nets standard once we kind of split, and

586
00:30:20,000 --> 00:30:21,680
then dot net Standard was kind of the way for

587
00:30:21,680 --> 00:30:23,599
a little while and then we realized, okay, let's just

588
00:30:23,680 --> 00:30:25,599
open source dot net and we're going to go, and

589
00:30:25,640 --> 00:30:26,400
that's good his future.

590
00:30:26,680 --> 00:30:28,839
Speaker 2: Well, and because the PCL approachment that every time you

591
00:30:28,880 --> 00:30:30,839
added a platform and it added complexy to everyone else,

592
00:30:30,839 --> 00:30:32,559
like it was an N over N minus one problem

593
00:30:32,640 --> 00:30:34,960
and it just got bad. Yeah as the count went up.

594
00:30:35,440 --> 00:30:38,000
Speaker 3: Yeah, and it's and you also ran into hey, this

595
00:30:38,039 --> 00:30:40,039
is supported on this platform. So you still needed to

596
00:30:40,079 --> 00:30:43,400
do some checks, right, Yeah, And to a degree, you

597
00:30:43,400 --> 00:30:45,640
still need to do certain checks depending on what you're

598
00:30:45,680 --> 00:30:47,480
doing and how you're using p and voke and whatnot,

599
00:30:47,480 --> 00:30:50,400
Like there are certain educating conditions that do matter that

600
00:30:50,440 --> 00:30:53,799
you need to check. But back in those days when

601
00:30:53,799 --> 00:30:55,640
I was doing WPF and silver Light, I was doing

602
00:30:55,680 --> 00:30:58,160
a lot of if deaf and then checking for certain

603
00:30:58,160 --> 00:31:01,680
compiler flags right right when I'm doing my you know,

604
00:31:01,720 --> 00:31:04,000
where should I find the NDI library. What's it called

605
00:31:04,039 --> 00:31:08,559
on this platform? That is a native if statement in

606
00:31:08,680 --> 00:31:11,799
c sharp. Nice, So that is compiled into each version

607
00:31:11,880 --> 00:31:14,079
and that check is being done at runtime.

608
00:31:14,240 --> 00:31:16,759
Speaker 2: Okay, all right, which he also gives you room for

609
00:31:16,839 --> 00:31:19,839
new versions and new configurations. It should just work.

610
00:31:19,920 --> 00:31:21,799
Speaker 1: Yeah, right, all right, this is a good time. We're

611
00:31:21,799 --> 00:31:24,279
going to take a break, I guess and about halfway

612
00:31:24,279 --> 00:31:27,279
through the show stick around after these very important messages,

613
00:31:27,319 --> 00:31:32,759
we'll be right back with more from Elias Purinin. You know,

614
00:31:32,920 --> 00:31:35,960
dot net six has officially reached the end of support,

615
00:31:36,000 --> 00:31:38,960
and now is the time to upgrade. Dot Net eight

616
00:31:39,119 --> 00:31:43,119
is well supported on AWS. Learn more at aws dot

617
00:31:43,160 --> 00:31:50,000
Amazon dot com, slash dot net. And we're back. It's

618
00:31:50,000 --> 00:31:53,079
dot net Rocks. I'm Carl Franklin, that's Richard Campbell, hey,

619
00:31:53,240 --> 00:31:55,960
and that's Elias Purinin. We're talking p and voke and

620
00:31:56,119 --> 00:31:59,039
audio and video stuff that you can do in dot

621
00:31:59,119 --> 00:32:03,799
net and c sharp. Now you've written a rapper for NDI,

622
00:32:03,839 --> 00:32:08,279
but you've also written rappers for other native you know,

623
00:32:08,559 --> 00:32:12,240
libraries and things. What's what's another cool one you want

624
00:32:12,240 --> 00:32:12,759
to talk about?

625
00:32:12,880 --> 00:32:17,839
Speaker 3: So for my NDI multiview, which kind of which is

626
00:32:17,880 --> 00:32:19,880
where all this p and voke. Goodness came from for

627
00:32:20,000 --> 00:32:22,319
me and where I saw the light of pnvoke and

628
00:32:22,480 --> 00:32:26,920
dot net in general. I as part of that, I

629
00:32:27,000 --> 00:32:31,119
needed to write against the NDI Advanced SDK because I

630
00:32:31,160 --> 00:32:33,680
wanted to be able to send out multiview outputs in

631
00:32:33,880 --> 00:32:38,720
a technology called NDI HX. So NDI has two major flavors.

632
00:32:38,759 --> 00:32:42,400
There's HX, which is compressed either H two sixty four

633
00:32:42,599 --> 00:32:46,119
H two sixty five or the full bandwidth version, which

634
00:32:46,160 --> 00:32:48,680
is used as something called speed HQ.

635
00:32:48,799 --> 00:32:54,279
Speaker 2: Because I want to make my Ethernet cables glow yes white.

636
00:32:54,440 --> 00:32:57,359
Speaker 1: Speed HQ maybe a misnomer, let's see.

637
00:32:57,640 --> 00:33:01,640
Speaker 2: Yeah, there's a lot of data in this stuff HQ.

638
00:33:03,640 --> 00:33:08,440
Speaker 3: They're big frames, but yet still compressed. So that's that's

639
00:33:08,480 --> 00:33:12,599
the thing. One thing a lossless compression, A lossless compression exactly.

640
00:33:12,680 --> 00:33:16,480
Speaker 2: Yeah, where two sixty four five are both loss e compressions.

641
00:33:16,559 --> 00:33:19,680
Speaker 3: Yeah. So one of the but one of the reasons

642
00:33:19,720 --> 00:33:23,079
I want to do the HX output is because there's

643
00:33:23,519 --> 00:33:27,839
two decode H two sixty four two sixty five. Pretty

644
00:33:27,920 --> 00:33:30,119
much anything on the planet can do that real time now,

645
00:33:30,720 --> 00:33:32,839
and there's a lot of devices coming out now that

646
00:33:33,160 --> 00:33:37,200
if they do NDID code they only do HX, so

647
00:33:37,440 --> 00:33:40,920
for so for me, I wanted to be able to

648
00:33:40,960 --> 00:33:43,880
send out an NDI feed as HX so that we

649
00:33:43,920 --> 00:33:46,279
could send it to those devices. Opens up a couple

650
00:33:46,400 --> 00:33:50,559
other categories two and so I went and took a look,

651
00:33:50,559 --> 00:33:52,640
and there's there were a bunch of N Video. There

652
00:33:52,640 --> 00:33:55,240
were some nvideo wrappers out there already for c SHARP

653
00:33:55,920 --> 00:33:58,759
because what every if you've got an N video graphics card,

654
00:33:58,799 --> 00:34:01,240
you have access to something called the end video encoder

655
00:34:01,640 --> 00:34:05,000
or en VANC. And so this is the hardware on

656
00:34:05,039 --> 00:34:08,320
your card based H two sixty four, H two sixty

657
00:34:08,320 --> 00:34:11,159
five and depending on new your card is av one.

658
00:34:11,440 --> 00:34:13,440
Speaker 2: Isn't this Kuda under the hood.

659
00:34:13,480 --> 00:34:16,199
Speaker 3: So it can use Kuda under the hood. There's also

660
00:34:16,320 --> 00:34:20,480
ways to access it via DirectX and with OpenGL context

661
00:34:20,639 --> 00:34:23,639
I believe, which gives you a little bit of more platform.

662
00:34:23,679 --> 00:34:27,320
Speaker 2: See look at this using video cards for video not AI.

663
00:34:27,559 --> 00:34:28,519
I'm so excited.

664
00:34:28,800 --> 00:34:32,360
Speaker 3: It's a cool X it's your foot, isn't it cool?

665
00:34:32,400 --> 00:34:35,679
We can actually use GPUs for video again, Yeah, what

666
00:34:35,719 --> 00:34:38,679
a concept. It's amazing. To give you an idea of

667
00:34:38,719 --> 00:34:40,840
how fast it encodes though, I can put a ten

668
00:34:40,880 --> 00:34:43,559
EIGHTP sixty or I can put a ten ADP nineteen

669
00:34:43,599 --> 00:34:47,519
twenty by ten eighty video frame into endvanc and get

670
00:34:47,559 --> 00:34:51,199
an encoded frame out in about two to three milliseconds.

671
00:34:51,440 --> 00:34:55,039
Speaker 2: Wow, Jayvers Miles and marsh Miles. And you're not talking

672
00:34:55,039 --> 00:34:58,280
at fifty ninety here, you're talking about like a ten eighty.

673
00:34:58,440 --> 00:35:00,840
Speaker 3: Yeah, a ten eighty. Like you know, I've got a

674
00:35:00,840 --> 00:35:03,039
machine here that's got like a forty sixty, forty seventy.

675
00:35:03,079 --> 00:35:05,639
It is like two three milliseconds. It's nothing, it's nothing.

676
00:35:05,719 --> 00:35:07,599
Speaker 2: Yeah, now you'll be able to keep up. You could

677
00:35:07,639 --> 00:35:10,760
do a bunch of those, like, yeah, sixty frames per second?

678
00:35:10,760 --> 00:35:14,400
How many can you do? Five off that card real time?

679
00:35:14,760 --> 00:35:17,639
Speaker 3: So again depends on the card. That card I think

680
00:35:17,719 --> 00:35:20,639
is just hardware is limited by the drivers to five.

681
00:35:21,079 --> 00:35:24,360
But like if you go with the RTXA four thousands

682
00:35:24,480 --> 00:35:26,159
or like the really professional grade.

683
00:35:25,960 --> 00:35:28,000
Speaker 2: Cards, which is what they're bill for. Yeah, the work

684
00:35:29,599 --> 00:35:33,679
those workstation class ones are designed for multiple parallel threads,

685
00:35:33,719 --> 00:35:36,599
which is not great for gaming, but for this application,

686
00:35:36,639 --> 00:35:37,280
that's brilliant.

687
00:35:37,280 --> 00:35:41,239
Speaker 3: Oh, they are absolutely beefy cards. They're super cool.

688
00:35:41,360 --> 00:35:41,639
Speaker 2: Yeah.

689
00:35:41,679 --> 00:35:44,159
Speaker 1: Anybody who knows what I do knows that I create

690
00:35:44,239 --> 00:35:47,760
videos and things, and I'm a big fan of Adobe Premiere.

691
00:35:47,880 --> 00:35:51,119
But I remember in the days when Adobe Premiere Pro

692
00:35:51,920 --> 00:35:56,239
didn't have access to the GPU for rendering, and it

693
00:35:56,320 --> 00:35:59,719
was just using the CPU and it was slow, and

694
00:36:00,239 --> 00:36:01,960
it's like, oh yeah, you got to go turn on

695
00:36:02,039 --> 00:36:04,599
this thing. And then it was it was faster, it

696
00:36:04,639 --> 00:36:08,519
was much faster. Now now I can take an our

697
00:36:08,679 --> 00:36:12,559
video and render it on my I nine, you know,

698
00:36:12,679 --> 00:36:16,320
with my Nvidia card in maybe five minutes.

699
00:36:16,599 --> 00:36:16,840
Speaker 2: Yeah.

700
00:36:17,119 --> 00:36:20,320
Speaker 3: Yeah, it's that's that's really cool. That's that's the beauty

701
00:36:20,320 --> 00:36:21,159
of the modern GPU.

702
00:36:21,480 --> 00:36:21,960
Speaker 2: Yeah.

703
00:36:22,039 --> 00:36:24,599
Speaker 3: So, and because I've got access to that, you know,

704
00:36:24,880 --> 00:36:28,199
I've got access to those two GPU n code and decode.

705
00:36:28,199 --> 00:36:29,880
Like all of a sudden, I can sort of get

706
00:36:29,920 --> 00:36:32,199
around licensing around h two sixty four and two sixty

707
00:36:32,199 --> 00:36:34,960
five because that's a whole weird legal beast that I'm

708
00:36:34,960 --> 00:36:35,800
not even going to touch.

709
00:36:36,039 --> 00:36:40,159
Speaker 1: So you created wrap around the end Video encoery encoder,

710
00:36:40,400 --> 00:36:41,199
so INVEC.

711
00:36:41,320 --> 00:36:44,199
Speaker 3: Yeah, So ENVEC gives you if you go on end

712
00:36:44,239 --> 00:36:47,679
video site, you can download the CSDK for ENDVEC and

713
00:36:47,960 --> 00:36:48,760
I call it end bank.

714
00:36:48,840 --> 00:36:51,079
Speaker 2: I don't know why, but I think you're right.

715
00:36:51,320 --> 00:36:54,519
Speaker 3: Yeah, that's that's how I'll refer to it. I'm used

716
00:36:54,519 --> 00:36:57,119
to that one. So you download that, you get a

717
00:36:57,119 --> 00:36:59,679
c API. But what's interesting in the if you look

718
00:36:59,679 --> 00:37:03,159
at the and we've provided links. I've provided a bunch

719
00:37:03,199 --> 00:37:05,559
of show links for this. You can find it if

720
00:37:05,599 --> 00:37:08,360
you look uptractice dot encoders on GitHub.

721
00:37:08,679 --> 00:37:10,239
Speaker 1: We'll put them on the main page too.

722
00:37:10,320 --> 00:37:12,119
Speaker 3: I have yeah, so we'll be on the main page.

723
00:37:12,159 --> 00:37:12,360
Speaker 2: Two.

724
00:37:12,800 --> 00:37:15,599
Speaker 3: So if you look up, if you look up that library,

725
00:37:15,599 --> 00:37:18,360
you'll notice that I actually only have one direct P

726
00:37:18,440 --> 00:37:21,559
and voke function call into envank, and that is to

727
00:37:21,639 --> 00:37:25,559
initialize the library and get back astruct. Now what does

728
00:37:25,599 --> 00:37:30,480
that struct contain. It contains a bunch of unmanaged function

729
00:37:30,599 --> 00:37:34,440
pointers to whatever version of the API I'm referencing, so

730
00:37:34,519 --> 00:37:38,239
for backwards and forwards compatibility, like if i'm I can

731
00:37:38,360 --> 00:37:41,679
say I'm on version twelve, I've compiled against version twelve

732
00:37:41,719 --> 00:37:45,320
of the nvank SDK, So that gives me access to

733
00:37:45,480 --> 00:37:49,119
anybody that's running n Video Drivers five twenty and above,

734
00:37:49,400 --> 00:37:53,480
which is striking a nice balance between supporting some legacy

735
00:37:53,519 --> 00:37:55,800
stuff like that goes back I think to about twenty nineteen,

736
00:37:55,880 --> 00:37:58,960
twenty twenty, but not being so new that like you

737
00:37:59,000 --> 00:38:01,119
need a fifty ninety and all the latest drivers to

738
00:38:01,159 --> 00:38:01,719
run it right.

739
00:38:01,920 --> 00:38:04,440
Speaker 2: Yeah, and well, let's face it, the fifty ninety is

740
00:38:04,440 --> 00:38:08,840
crazy overcow for virtually everything pretty much. Yeah, except we're

741
00:38:08,880 --> 00:38:10,960
just just taking money off you. You know, I'm realizing

742
00:38:11,039 --> 00:38:15,880
there's Envy Inc and Envy Deck, so I can't I

743
00:38:15,920 --> 00:38:17,920
don't think he can say n bank because you can't

744
00:38:17,960 --> 00:38:19,960
say env deck. Ah.

745
00:38:20,039 --> 00:38:22,400
Speaker 1: True, that would be the decoder version.

746
00:38:22,480 --> 00:38:24,679
Speaker 2: Yeah, there's an encoder and a decoder. This is legit,

747
00:38:24,800 --> 00:38:28,440
you know, we get this. Yeah, so I think if

748
00:38:28,440 --> 00:38:30,079
I'm going to go for a naming consisting, it's going

749
00:38:30,159 --> 00:38:33,719
to be Envy inc, an Envy Deck, envanc en v deck.

750
00:38:33,800 --> 00:38:37,679
I like that. They're still awkward, just bank deck like

751
00:38:37,800 --> 00:38:40,519
modem because n bank is easier to say no toys

752
00:38:40,519 --> 00:38:42,880
about them. But there's nothing nothing you do about the decoder.

753
00:38:42,920 --> 00:38:43,480
It's glunky.

754
00:38:43,599 --> 00:38:46,039
Speaker 3: Yeah. Yeah, at least it's not WPF.

755
00:38:46,239 --> 00:38:46,920
Speaker 2: They'll save me.

756
00:38:49,280 --> 00:38:51,320
Speaker 3: Who was who was it that was ranting about that

757
00:38:51,360 --> 00:38:54,840
way back in the day we can't have actros w No,

758
00:38:55,280 --> 00:38:55,880
it was it.

759
00:38:55,840 --> 00:38:58,000
Speaker 2: Was Brad Abrams who said, listen, if we give the

760
00:38:58,039 --> 00:39:01,679
project a good code name, it gets a tear product name. Yeah.

761
00:39:01,719 --> 00:39:04,840
So that's why the code name for silver Light was

762
00:39:05,039 --> 00:39:08,719
WPF slash E because that's the worst code name ever.

763
00:39:08,800 --> 00:39:10,159
So the product name was awesome.

764
00:39:10,239 --> 00:39:13,480
Speaker 1: I was just waiting for Windows Transaction Framework, which would

765
00:39:13,480 --> 00:39:15,079
be WTF.

766
00:39:17,960 --> 00:39:19,519
Speaker 2: He said, where did my data go?

767
00:39:19,840 --> 00:39:22,800
Speaker 3: So, but getting back to the getting back to the

768
00:39:23,519 --> 00:39:26,920
n bank wrapper library. So there's only one direct p

769
00:39:27,039 --> 00:39:29,440
in voke function call in, and that gives you a

770
00:39:29,519 --> 00:39:33,440
struck back and that struct has nothing but function pointers, right,

771
00:39:33,480 --> 00:39:35,800
and that's how you actually interact with the API. That's

772
00:39:35,840 --> 00:39:39,159
how they're maintaining that backwards compatibility. So even if I'm

773
00:39:39,199 --> 00:39:39,559
running the.

774
00:39:39,760 --> 00:39:42,480
Speaker 2: This is really not that horrible, right. Once you've got connected,

775
00:39:42,480 --> 00:39:44,559
it's really smart. Then you're just feeding it data. It's

776
00:39:44,599 --> 00:39:45,199
just just dream.

777
00:39:45,360 --> 00:39:48,760
Speaker 3: And then throughout that library, I then have a bunch

778
00:39:48,800 --> 00:39:53,039
of Marshal delegate to function pointer. I forget the exact

779
00:39:54,119 --> 00:39:58,480
get delegate for function pointer calls, so it's Marshal dot

780
00:39:58,519 --> 00:40:01,639
debt get delegate for function pointer. I pass it in

781
00:40:02,199 --> 00:40:06,559
the end pointer, you know, native end pointer for each

782
00:40:06,599 --> 00:40:09,320
of those function each of those function pointers. And I

783
00:40:09,440 --> 00:40:13,519
now have a first class c sharp delegate that I

784
00:40:13,559 --> 00:40:17,320
can call. Great, so now I can take my whatever

785
00:40:17,360 --> 00:40:20,119
memory I've got allocated, that's got my raw video frame.

786
00:40:20,519 --> 00:40:22,679
I can now say, okay, here's a point of that

787
00:40:22,760 --> 00:40:25,559
memory end bank. Here you go, give me a frame back,

788
00:40:26,079 --> 00:40:27,840
and it all just works. And I'm doing all of

789
00:40:27,880 --> 00:40:29,639
these calls in c sharp.

790
00:40:29,440 --> 00:40:31,519
Speaker 1: And if it changes, you don't care because maybe the

791
00:40:31,559 --> 00:40:34,960
memory changes, maybe the pointer changes, but that's.

792
00:40:34,719 --> 00:40:38,199
Speaker 3: Fine, exactly. So I'm I'm shielded from all that stuff.

793
00:40:38,199 --> 00:40:40,639
I get the advantages of native, of the speed of

794
00:40:40,639 --> 00:40:43,559
the native code, but I'm also able to and i

795
00:40:43,599 --> 00:40:46,199
can access all these native libraries. But I've also got

796
00:40:46,239 --> 00:40:48,519
a lot of the protections that c sharp gives me

797
00:40:48,679 --> 00:40:49,440
out of the box.

798
00:40:49,719 --> 00:40:52,840
Speaker 1: Yep, You've got another layer of abstraction there, which is

799
00:40:52,920 --> 00:40:53,760
always a good.

800
00:40:53,559 --> 00:40:55,840
Speaker 3: Thing, exactly. And as long as I've got all of

801
00:40:55,880 --> 00:40:57,960
my strucks set up the right way, and I've got

802
00:40:58,159 --> 00:41:01,239
you know, and I've been very careful about how I've

803
00:41:01,239 --> 00:41:04,280
instructed dot net about how these structs are laid out,

804
00:41:04,519 --> 00:41:07,199
everything just works. That's a big.

805
00:41:07,039 --> 00:41:10,159
Speaker 1: Asterisk, though, I jw technology.

806
00:41:09,519 --> 00:41:11,360
Speaker 3: It just works. Technology it works works.

807
00:41:11,519 --> 00:41:13,239
Speaker 2: Yeah, what's the asterisk?

808
00:41:13,400 --> 00:41:16,440
Speaker 3: So in some cases you do have to be very

809
00:41:16,440 --> 00:41:21,400
specific about what the unmanaged code is expecting in terms

810
00:41:21,440 --> 00:41:25,599
of how is this struct laid out? How should this

811
00:41:25,880 --> 00:41:28,840
If I'm p invoking how should this function be called?

812
00:41:30,039 --> 00:41:34,480
Because there's the there's standard call. In the unmanaged world,

813
00:41:34,519 --> 00:41:36,159
we have standard call, which is the way that we

814
00:41:36,280 --> 00:41:40,320
usually call into like a WIN thirty two API for example,

815
00:41:40,960 --> 00:41:44,679
and standard call one of the versions it's the caller

816
00:41:44,760 --> 00:41:47,440
is responsible for cleaning up the stack once the function returns,

817
00:41:47,920 --> 00:41:50,480
and in the other way, the call e is responsible

818
00:41:50,519 --> 00:41:52,760
for cleaning up the stack. It's the collie that's responsible

819
00:41:52,760 --> 00:41:55,760
for cleaning up the stack in a standard call call,

820
00:41:56,480 --> 00:42:00,840
whereas with a with a C decal call, the caller

821
00:42:00,920 --> 00:42:03,559
is responsible for cleaning up the stack. Which is why

822
00:42:03,599 --> 00:42:06,239
and C you're able to do like a print aff

823
00:42:06,400 --> 00:42:08,880
with your string, your format string, and then you can

824
00:42:08,920 --> 00:42:12,039
put as many parameters after that as you want because

825
00:42:12,079 --> 00:42:15,360
it's an also for the standard call. That's why if

826
00:42:15,400 --> 00:42:17,880
you ever crack open you know, a C plus plus

827
00:42:17,920 --> 00:42:21,360
library in a tool like GEDRA, reverse engineering tool like GEDRA,

828
00:42:21,840 --> 00:42:24,639
you'll see these really awful mangled names like you know,

829
00:42:24,800 --> 00:42:29,559
get function pointer at three and that at three tells

830
00:42:29,599 --> 00:42:33,920
you this version this overload is expecting three parameters, no more,

831
00:42:33,960 --> 00:42:36,599
no less, okay, and if you call it with more

832
00:42:37,440 --> 00:42:38,440
things could happen.

833
00:42:40,480 --> 00:42:45,719
Speaker 1: Self documenting sort kind of sort of sort of you

834
00:42:45,719 --> 00:42:47,480
don't know what they are, but that's why you have

835
00:42:47,519 --> 00:42:49,519
to see sure, you.

836
00:42:49,440 --> 00:42:51,719
Speaker 3: Know, you could just you know, like anything else, like

837
00:42:51,800 --> 00:42:53,719
sometimes you just got to poke the function calls and

838
00:42:53,760 --> 00:42:55,800
see what happens. Just like let's call it with five.

839
00:42:55,880 --> 00:42:56,760
Let's see if it works.

840
00:42:57,239 --> 00:42:59,880
Speaker 1: Now, you had a specific need to create this wrapper,

841
00:43:00,480 --> 00:43:03,960
but what might other people need to use it for?

842
00:43:04,360 --> 00:43:07,719
Speaker 3: So for Endvank, it's part of my philosophy of creating

843
00:43:07,719 --> 00:43:10,400
some of these rappers was like was to was to

844
00:43:10,440 --> 00:43:12,760
show that, look, if you want to get this high

845
00:43:12,800 --> 00:43:15,920
performance real time audio and video, you can totally use

846
00:43:15,960 --> 00:43:19,320
a higher level language like c sharp because when you

847
00:43:19,440 --> 00:43:22,280
need to drop down and get that crazy speed, you can.

848
00:43:22,519 --> 00:43:25,000
M h. So let's talk about crazy speed. Let's talk

849
00:43:25,000 --> 00:43:27,280
about unsafe code, and let's talk pointers.

850
00:43:27,639 --> 00:43:31,360
Speaker 1: Yeah, so love unsafe code reminds me of my teenage

851
00:43:31,440 --> 00:43:34,280
days driving a car at one hundred miles an hour

852
00:43:34,760 --> 00:43:40,000
through the town. Chickens flying everywhere, mothers pulling their children

853
00:43:40,039 --> 00:43:40,639
off the street.

854
00:43:41,320 --> 00:43:46,920
Speaker 3: Go ahead, that sounds like an interesting hobby. I just tried.

855
00:43:46,920 --> 00:43:50,039
Speaker 1: I had to pick up the feathers afterwards, though, I had.

856
00:43:49,800 --> 00:43:52,880
Speaker 3: Oh man MESSI my biggest adventure of driving a car

857
00:43:52,960 --> 00:43:54,519
was knocking over construction fences.

858
00:43:54,880 --> 00:43:57,119
Speaker 1: There you go, all right, well that could be unsafe.

859
00:43:57,320 --> 00:44:00,239
Speaker 3: Yeah. So if you compile your C sharp code with

860
00:44:00,360 --> 00:44:02,719
you know this, with slash unsafe for you marketing your

861
00:44:02,719 --> 00:44:05,599
project file that you want unsafe code, then you can

862
00:44:05,679 --> 00:44:08,679
use what's called Then you can use the unsafe keyword.

863
00:44:09,079 --> 00:44:11,840
Now what does unsafe do? This allows you to do

864
00:44:11,880 --> 00:44:15,039
stuff like pin objects in memory and get raw function

865
00:44:15,119 --> 00:44:20,719
point and get raw pointers. So you would think, okay,

866
00:44:20,760 --> 00:44:23,880
So a common misconception is that C sharp doesn't have pointers.

867
00:44:24,039 --> 00:44:27,159
Oh yes it does. Let me tell you about them.

868
00:44:27,480 --> 00:44:30,360
So there is if you're working in an unsafe context,

869
00:44:30,360 --> 00:44:34,239
there is nothing stopping you from calling Marshall dot alec

870
00:44:34,440 --> 00:44:37,119
h Global and saying I want a big chunk of

871
00:44:37,199 --> 00:44:41,239
memory and it'll go cool. Here's a pointer that memory.

872
00:44:41,360 --> 00:44:45,639
You can then cast that to whatever struck type you

873
00:44:45,679 --> 00:44:51,000
want and bam, all of a sudden, I have pointer

874
00:44:51,119 --> 00:44:53,519
de referencing arrows in my C sharp code.

875
00:44:53,599 --> 00:44:56,559
Speaker 1: But you said the magic word though, which is pinning. Yeah,

876
00:44:56,599 --> 00:44:59,599
if you don't pin it, it could move around on

877
00:44:59,679 --> 00:45:02,360
you and you go to access it and you're writing

878
00:45:02,400 --> 00:45:04,159
over something and security.

879
00:45:04,599 --> 00:45:05,039
Speaker 2: We have a.

880
00:45:05,000 --> 00:45:05,760
Speaker 1: Problem over here.

881
00:45:05,880 --> 00:45:06,679
Speaker 2: Bad things happen.

882
00:45:06,880 --> 00:45:08,920
Speaker 3: Oh yeah, you could. You could get into big problems

883
00:45:08,960 --> 00:45:09,519
real fast.

884
00:45:09,920 --> 00:45:13,320
Speaker 1: So but pinning is the key. It basically says, don't

885
00:45:13,360 --> 00:45:15,559
move from this spot right here.

886
00:45:15,679 --> 00:45:15,880
Speaker 2: Yeah.

887
00:45:16,679 --> 00:45:20,800
Speaker 3: Now, from my experience, I when I've been working in

888
00:45:20,880 --> 00:45:23,039
modern dot net, I found that I've had to do

889
00:45:23,280 --> 00:45:25,599
pinning a lot less than I used to. Yeah, Like,

890
00:45:25,639 --> 00:45:27,519
it seems like there's been a lot of work going

891
00:45:27,559 --> 00:45:29,960
behind the scenes. And it feels like that is because

892
00:45:30,000 --> 00:45:34,119
of dot net running on mobile platforms and running on

893
00:45:34,199 --> 00:45:37,800
mac os. Like that work seems to have you know,

894
00:45:38,079 --> 00:45:41,599
the native interrupt story is way different from like the

895
00:45:41,599 --> 00:45:44,639
dot net one one two oh days. But you can,

896
00:45:44,719 --> 00:45:46,639
but you can totally allocate just a block of memory,

897
00:45:46,679 --> 00:45:49,159
and I actually do this, like for my advanced SDK

898
00:45:49,320 --> 00:45:51,119
rapper and for some of the encoding that we're doing

899
00:45:51,119 --> 00:45:54,760
behind the scenes. What NDI expects when I send a

900
00:45:54,960 --> 00:45:59,039
compressed frame is that it wants in memory physically laid out.

901
00:45:59,159 --> 00:46:04,000
It wants the struct header that contains information about resolution,

902
00:46:04,400 --> 00:46:08,119
frame rate, data length, and then after that in memory

903
00:46:08,280 --> 00:46:11,000
should follow the h two sixty four bitstream. So the

904
00:46:11,039 --> 00:46:14,480
actual stuff that comes out of the encoder, right, that's

905
00:46:14,519 --> 00:46:16,679
a little bit hard to do in see you can

906
00:46:16,760 --> 00:46:18,920
do that. You could just allocate a bunch of memory

907
00:46:19,639 --> 00:46:23,159
for whatever memory you want for your frame size, plus

908
00:46:23,199 --> 00:46:25,239
you know, say forty four bites for your for the

909
00:46:25,280 --> 00:46:29,840
struct header, and you new memcopy in C it's a

910
00:46:30,039 --> 00:46:31,840
in C sharp, it's a little bit more difficult to

911
00:46:31,840 --> 00:46:33,880
do that, but you can still do that because you

912
00:46:33,880 --> 00:46:37,159
can allocate memory marshall allocate global that's equivalent to your

913
00:46:37,519 --> 00:46:41,079
to your mallek and sea land. You can then cast that.

914
00:46:41,960 --> 00:46:44,480
You then cast that to a pointer to whatever struct

915
00:46:44,480 --> 00:46:48,719
type you're dealing with, and in your struct declaration you

916
00:46:48,760 --> 00:46:53,800
can add attributes that say hey, this struct layout is sequential,

917
00:46:54,039 --> 00:46:57,320
so don't move stuff. So dot net compiler, don't try

918
00:46:57,320 --> 00:47:01,559
to get clever with moving my different fields around to

919
00:47:02,119 --> 00:47:05,159
do memory alignment or you know, save space or do

920
00:47:05,199 --> 00:47:08,079
anything clever. Just like how I've laid this out, Like

921
00:47:08,119 --> 00:47:10,480
if I if my first field is an ind to,

922
00:47:10,559 --> 00:47:12,480
my second field is a long, and my third field

923
00:47:12,559 --> 00:47:15,320
is a short, like I want it laid out exactly

924
00:47:15,400 --> 00:47:15,840
like that in.

925
00:47:15,840 --> 00:47:18,400
Speaker 1: Memory Yeah, sequentially exact.

926
00:47:18,599 --> 00:47:19,159
Speaker 2: Yeah.

927
00:47:19,199 --> 00:47:21,599
Speaker 1: So if you do that, you have your own safe code,

928
00:47:21,639 --> 00:47:26,960
your global maloc and you pin it is it really unsafe?

929
00:47:27,079 --> 00:47:30,360
Speaker 3: So you can still dereference, you know, something outside of

930
00:47:30,360 --> 00:47:33,000
the bounds of the memory that you've allocated. So in

931
00:47:33,079 --> 00:47:35,599
terms of unsafe, it's kind of like saying, you know what,

932
00:47:35,639 --> 00:47:38,559
if you want to dip into doing you know, memory

933
00:47:38,599 --> 00:47:42,280
management and pointers and all that stuff yourself, you can

934
00:47:42,280 --> 00:47:45,800
totally do that. It's your foot, It's exactly c Sharp's

935
00:47:45,840 --> 00:47:48,039
like a big Swiss army knife, right, It's got all

936
00:47:48,079 --> 00:47:50,639
these different tools and abilities, and then you pull out

937
00:47:50,639 --> 00:47:53,079
the final one and it's a big friggin' you know,

938
00:47:53,400 --> 00:47:55,559
precision rifle, perfect for your foot.

939
00:47:56,360 --> 00:47:56,679
Speaker 2: Nice.

940
00:47:57,920 --> 00:48:00,679
Speaker 1: It's got everything, so it's not gonna it's not going

941
00:48:00,719 --> 00:48:02,920
to move on you, which is one of the problems

942
00:48:03,000 --> 00:48:05,880
and one of the reasons we have managed you know,

943
00:48:05,960 --> 00:48:09,519
frameworks in the first place, like that net. But you

944
00:48:09,559 --> 00:48:14,920
can still overcopy, under copy, like you said, de reference

945
00:48:14,960 --> 00:48:17,880
to the wrong thing. You can still do all those

946
00:48:17,920 --> 00:48:20,599
stupid things, and the compiler is probably not going to

947
00:48:20,679 --> 00:48:21,920
help you all that much.

948
00:48:22,679 --> 00:48:25,920
Speaker 3: But it also depends to how you're interacting with that

949
00:48:26,039 --> 00:48:28,880
data that you are or those or the pieces of

950
00:48:28,920 --> 00:48:32,519
memory that you're working without a low level because you

951
00:48:32,519 --> 00:48:35,880
can also take a byte pointer or a void pointer

952
00:48:36,039 --> 00:48:38,599
whatever you want, like say I've allocated a big chunk

953
00:48:38,599 --> 00:48:40,960
of memory, and I want to pass that chunk of

954
00:48:41,039 --> 00:48:45,679
memory to a managed function that expects a spam like

955
00:48:45,719 --> 00:48:49,159
a SPAN of byte I can create. I can instantiate

956
00:48:49,280 --> 00:48:53,440
a SPAN byte, pass in that pointer to memory and say, hey,

957
00:48:53,559 --> 00:48:55,400
this is you know, two thousand and forty eight four thousand,

958
00:48:55,440 --> 00:48:58,800
ninety six bytes long. I now have a SPAN rapper,

959
00:48:59,199 --> 00:49:02,679
like a first SPAN wrapper around this chunk of memory

960
00:49:02,679 --> 00:49:05,079
that is quote unquote unsafe, and I can do all

961
00:49:05,119 --> 00:49:06,920
of my dot net goodie things to it.

962
00:49:07,239 --> 00:49:07,440
Speaker 2: Right.

963
00:49:07,719 --> 00:49:12,119
Speaker 1: Yes, SPAN is a wonderful, wonderful construct.

964
00:49:11,599 --> 00:49:15,159
Speaker 3: And like I use that, for example to as part

965
00:49:15,199 --> 00:49:18,880
of encoding that ndiachex frame. I need to tell NDI

966
00:49:19,119 --> 00:49:21,880
here's how long the actual frame data is and all

967
00:49:21,880 --> 00:49:24,320
of the ancillary data, so like when this frame should

968
00:49:24,360 --> 00:49:27,800
be presented, that's how long this is. I have a

969
00:49:28,079 --> 00:49:31,719
parser at h two sixty four bitstream parser that is

970
00:49:31,719 --> 00:49:35,960
written in C sharp. It's all managed code that uses

971
00:49:36,039 --> 00:49:38,760
SPAN to go through and see, oh, here's where this

972
00:49:38,800 --> 00:49:41,119
part starts, here's where this part ends, here's what needs

973
00:49:41,159 --> 00:49:43,679
to be copied. So I'm doing all of that checking

974
00:49:43,679 --> 00:49:45,360
and it's I've got all the type safety and I've

975
00:49:45,400 --> 00:49:48,280
got all the bounds checking right, Yeah, so I'm not concerned.

976
00:49:48,559 --> 00:49:51,440
So I'm not as concerned about you know, overrunning underrunning,

977
00:49:51,480 --> 00:49:53,920
like as long as I'm as long as I'm instantiating

978
00:49:53,920 --> 00:49:56,840
with SPAN correctly. I've got all the type safety of

979
00:49:57,119 --> 00:49:57,639
C sharp.

980
00:49:58,519 --> 00:50:00,800
Speaker 1: And that's SPAN. We've talked about that that span before,

981
00:50:02,119 --> 00:50:05,599
about span, and just remind us what it is from

982
00:50:05,599 --> 00:50:09,679
what I remember, it's sort of like a fixed position

983
00:50:09,960 --> 00:50:13,360
array of stuff that isn't going to move around under you, right.

984
00:50:13,360 --> 00:50:16,119
Speaker 3: And it wraps it without doing memory copies.

985
00:50:16,480 --> 00:50:16,840
Speaker 2: Yeah.

986
00:50:16,880 --> 00:50:19,119
Speaker 3: So and then if you want, say you want to

987
00:50:19,159 --> 00:50:21,079
get you know, you've got a SPAN that's two that

988
00:50:21,119 --> 00:50:24,639
wraps a two megabyte bite array or a two megabyte

989
00:50:24,639 --> 00:50:28,679
bite pointer, and you want to get the data at

990
00:50:28,719 --> 00:50:32,280
offset five hundred and twelve K to oneenty twenty four K.

991
00:50:32,800 --> 00:50:34,760
But you don't want to copy that. You just want

992
00:50:34,800 --> 00:50:37,800
a you just want a slice of a slice of

993
00:50:37,800 --> 00:50:40,559
that to view it basically or to do something else

994
00:50:40,599 --> 00:50:41,920
with it, but you don't want to make a copy

995
00:50:41,920 --> 00:50:44,800
of it. You can say span dot slice I believe,

996
00:50:45,440 --> 00:50:48,559
and that will give you a SPAN without doing any

997
00:50:48,599 --> 00:50:52,320
memory copies that starts at that offset that you specify cool,

998
00:50:52,360 --> 00:50:55,320
so then you can do whatever you want to that nice, Yeah.

999
00:50:55,039 --> 00:50:55,639
Speaker 2: Very nice.

1000
00:50:56,280 --> 00:50:59,880
Speaker 1: I remember talking to Mark Mark Heath of an i

1001
00:51:00,039 --> 00:51:02,960
udio fame about spans when I first heard about them,

1002
00:51:03,760 --> 00:51:06,679
and I think he implemented them behind the scenes in

1003
00:51:06,719 --> 00:51:09,400
and audio and made it more performance and safer.

1004
00:51:09,519 --> 00:51:12,360
Speaker 3: Oh yeah, and it's it. What is really awesome about

1005
00:51:12,440 --> 00:51:14,199
is you get you also get access to all the

1006
00:51:14,239 --> 00:51:16,840
first class stuff like for each four loops. Yeah, and

1007
00:51:16,880 --> 00:51:19,239
you're not having to do that manual You're not having

1008
00:51:19,239 --> 00:51:22,079
to do the manual pointer arithmetic as well.

1009
00:51:22,320 --> 00:51:22,519
Speaker 2: Yeah.

1010
00:51:22,559 --> 00:51:24,760
Speaker 3: Again you can in unsafe mode. You can totally do

1011
00:51:24,840 --> 00:51:27,760
that and it will, it behaves exactly. But you have

1012
00:51:27,840 --> 00:51:28,719
to really think about it.

1013
00:51:28,920 --> 00:51:31,000
Speaker 1: Yeah, more than I want to think about plumbing.

1014
00:51:31,360 --> 00:51:34,519
Speaker 3: Yeah, but you think about it once and it's done.

1015
00:51:34,679 --> 00:51:38,599
Speaker 2: That's why we like the library builders too. Absolutely may

1016
00:51:38,960 --> 00:51:42,039
make our lives easier for this stuff. I might include

1017
00:51:42,039 --> 00:51:44,519
a link to an audio now on GitHub. I know

1018
00:51:44,559 --> 00:51:47,719
I referred to it in the comment as on CodePlex,

1019
00:51:47,880 --> 00:51:49,960
but they moved. Well.

1020
00:51:50,000 --> 00:51:52,599
Speaker 3: Remember once upon a time stuff used to it was CodePlex.

1021
00:51:52,639 --> 00:51:54,880
Stuff also lived on code project for a long time.

1022
00:51:55,000 --> 00:51:56,360
Speaker 2: Yeah, code project. Yeah.

1023
00:51:56,519 --> 00:51:58,360
Speaker 3: Number of libraries that would just be like, hey, here's

1024
00:51:58,360 --> 00:51:59,599
the DLL. Go have fun.

1025
00:52:00,119 --> 00:52:03,039
Speaker 2: Then one day, I mean GitHub has won. Right, It's

1026
00:52:03,079 --> 00:52:06,239
almost not a conversation anymore, pretty much just the way

1027
00:52:06,239 --> 00:52:10,679
it is. Well, remember their original tagline was social coding,

1028
00:52:10,760 --> 00:52:13,840
and we realize how important that is, Like I look

1029
00:52:13,920 --> 00:52:17,400
to the issue log to understand the health of a project,

1030
00:52:18,079 --> 00:52:20,719
Like the way people talk about that code matters a lot.

1031
00:52:20,880 --> 00:52:25,000
Speaker 1: Yeah, oh yeah, intrinsics. Okay, what's that about.

1032
00:52:25,079 --> 00:52:29,039
Speaker 3: So not entirely related to p and voke, but it's

1033
00:52:29,320 --> 00:52:31,760
a big deal when it comes to performance and dot net.

1034
00:52:31,880 --> 00:52:34,480
And this is kind of one of the arguments about,

1035
00:52:34,800 --> 00:52:36,880
you know, should we write our high performance code in

1036
00:52:37,000 --> 00:52:39,119
C sharp or should we write our high performance code

1037
00:52:39,199 --> 00:52:42,280
in a lower level language like C. And one of

1038
00:52:42,320 --> 00:52:46,559
the items is I want to use hardware accelerated vector

1039
00:52:46,599 --> 00:52:51,760
operations or single instruction multiple data SI MD instructions. Where

1040
00:52:51,840 --> 00:52:54,039
this really comes into play is you know, think about

1041
00:52:54,079 --> 00:52:57,920
like you're doing matrix transformations way outside my pay grade.

1042
00:52:58,000 --> 00:52:59,519
I'm not even going to pretend that I'm good at

1043
00:52:59,559 --> 00:53:06,039
that stuff. There are instructions that many modern CPUs support

1044
00:53:06,360 --> 00:53:08,320
that allow you to say, you know, do a bunch

1045
00:53:08,360 --> 00:53:10,760
of additions all at the same time, or like, you know,

1046
00:53:10,840 --> 00:53:13,480
do four data rights at the same time instead of

1047
00:53:13,519 --> 00:53:15,480
having to do you know a four each a four

1048
00:53:15,519 --> 00:53:18,239
loop where it's like I'm going to process. Well, where

1049
00:53:18,280 --> 00:53:24,159
I do it the most is transforming filling black for example. Sure,

1050
00:53:24,199 --> 00:53:26,960
so big operation in my multiview is after every frame

1051
00:53:27,000 --> 00:53:29,000
I have an I have four or five frame buffer

1052
00:53:29,039 --> 00:53:31,960
setup that I draw to. And so after I'm done

1053
00:53:32,039 --> 00:53:34,880
drawing to, before I draw the next frame, the first

1054
00:53:34,920 --> 00:53:38,360
operation I need to do is fill black. So just clear,

1055
00:53:38,559 --> 00:53:41,079
just blank out that frame for all rows and then

1056
00:53:41,119 --> 00:53:45,039
for all columns exactly exactly. So if I do so,

1057
00:53:45,079 --> 00:53:47,719
if I do the purely naive version where I'm just

1058
00:53:47,920 --> 00:53:51,199
I'm literally writing black, you know, a black byte pixel

1059
00:53:51,719 --> 00:53:54,760
across all the pixels in that frame buffer. On one

1060
00:53:54,760 --> 00:53:57,880
of my target systems, that takes a millisecond. And now

1061
00:53:57,880 --> 00:54:00,519
you think, okay, a millisecond. So what if I'm running

1062
00:54:00,519 --> 00:54:03,639
at sixty frames per second, I get sixteen milliseconds in

1063
00:54:03,679 --> 00:54:06,719
which to realize a frame. Yeah, that's not a lot

1064
00:54:06,719 --> 00:54:10,079
of time, and so a full one to sixteenth of

1065
00:54:10,119 --> 00:54:13,880
that time is now spent just filling the thing with black.

1066
00:54:14,400 --> 00:54:16,800
If I go a little bit smarter and I say, okay,

1067
00:54:16,840 --> 00:54:20,199
I know that I'm essentially writing a constant, So I'm

1068
00:54:20,239 --> 00:54:23,679
just going to write a thirty two bit int, you know,

1069
00:54:23,760 --> 00:54:25,920
and then do skip four bytes out of time. So

1070
00:54:25,920 --> 00:54:28,639
I'll write four bytes skip, write four byte skip. That

1071
00:54:28,760 --> 00:54:30,760
time goes down to about two hundred and seventy one

1072
00:54:31,400 --> 00:54:33,880
or zero point two seven one milliseconds or two hundred

1073
00:54:33,880 --> 00:54:38,239
and seventy one microseconds. Right. Nice, So we've already saved.

1074
00:54:38,360 --> 00:54:40,480
So just doing that hack has saved us some time.

1075
00:54:41,079 --> 00:54:43,320
If I do sixty four bits, so I do longs,

1076
00:54:43,719 --> 00:54:46,320
I bring that time down to one hundred and ninety microseconds.

1077
00:54:46,800 --> 00:54:47,119
Speaker 2: Nice.

1078
00:54:47,679 --> 00:54:51,920
Speaker 3: If I use avx two, which is a single instruction

1079
00:54:52,000 --> 00:54:56,719
multiple data extension for the X eighty six platform, that

1080
00:54:56,760 --> 00:54:59,400
code is super crazy, and I will fully admit that chat,

1081
00:54:59,480 --> 00:55:01,559
GPT and lot helped me write that and make it

1082
00:55:01,599 --> 00:55:02,199
work at all.

1083
00:55:02,400 --> 00:55:03,599
Speaker 1: Ah excellent.

1084
00:55:03,760 --> 00:55:09,440
Speaker 3: Yes, but the original naive version took one millisecond one

1085
00:55:09,880 --> 00:55:15,880
forty three microseconds. The SIMD version took seventy two microseconds.

1086
00:55:16,280 --> 00:55:18,440
Speaker 1: Well, jeez, that's significant.

1087
00:55:18,480 --> 00:55:22,960
Speaker 3: Think about this. Yeah, significant, not only significant, but it's

1088
00:55:22,960 --> 00:55:27,719
in C sharp and I'm accessing and I'm accessing, say

1089
00:55:27,960 --> 00:55:33,159
I'm accessing raw hardware essentially raw hardware instructions. So instead

1090
00:55:33,159 --> 00:55:36,519
of having to write that performance critical code like normally

1091
00:55:36,599 --> 00:55:40,199
if you wanted to access AVX or SIMB instructions, you

1092
00:55:40,199 --> 00:55:42,760
would be going into C Like that's just that's just

1093
00:55:42,800 --> 00:55:44,039
a done deal, dude.

1094
00:55:44,280 --> 00:55:50,119
Speaker 1: You can now write the trippiest screensaver ever, Yes, in

1095
00:55:50,239 --> 00:55:53,599
C sharp. Yeah, I knew you would come to the

1096
00:55:53,719 --> 00:55:58,000
killer app and sooner or later we can find it's

1097
00:55:58,039 --> 00:55:58,639
finally here.

1098
00:55:58,639 --> 00:56:00,719
Speaker 3: We can finally do all the plasma moost scene effects

1099
00:56:00,760 --> 00:56:01,800
we've always wanted.

1100
00:56:01,719 --> 00:56:07,280
Speaker 1: Absolutely in hardware, but so which you can then ingest

1101
00:56:07,320 --> 00:56:10,360
into a v mix thing and you know, while you wait,

1102
00:56:10,719 --> 00:56:13,599
you could just you know, be rendering that stuff.

1103
00:56:13,840 --> 00:56:18,079
Speaker 3: Well yeah, exactly. Another place the SAMD is important for too,

1104
00:56:18,199 --> 00:56:20,599
is say I'm doing pixel format conversions where I know,

1105
00:56:21,440 --> 00:56:26,239
I you know, I'm i've NDI likes YUV four two two,

1106
00:56:26,360 --> 00:56:29,280
so I have. And the way the yav pixels work

1107
00:56:29,320 --> 00:56:32,480
is basically the human eye is more sensitive to brightness

1108
00:56:32,480 --> 00:56:35,239
than it is to changes in color. So what we're

1109
00:56:35,400 --> 00:56:38,119
what we can do on most modern displays is say, hey,

1110
00:56:38,159 --> 00:56:41,960
I'm going to encode my luminance. My brightness is going

1111
00:56:42,039 --> 00:56:46,599
to be encoded at full resolution so I have nineteen

1112
00:56:46,639 --> 00:56:50,119
twenty by ten eighty resolution for luma, and then for

1113
00:56:50,239 --> 00:56:52,360
my color data. I can take advantage of the fact

1114
00:56:52,360 --> 00:56:55,039
that the human eye kind of sucks, and I can

1115
00:56:55,760 --> 00:56:58,559
do I can encode a macropixel and say, for every

1116
00:56:59,159 --> 00:57:02,280
one bit of you and V data my chroma data,

1117
00:57:02,800 --> 00:57:06,239
that will be decoded into two pixels worth of color data.

1118
00:57:06,360 --> 00:57:08,239
So if I combine the luma and the chroma together,

1119
00:57:08,280 --> 00:57:09,840
I get reproduction of color.

1120
00:57:09,880 --> 00:57:14,480
Speaker 1: Why am I thinking of Gaussian splatting right now? Do

1121
00:57:14,519 --> 00:57:15,320
you know what that is?

1122
00:57:15,639 --> 00:57:16,199
Speaker 2: I don't.

1123
00:57:16,599 --> 00:57:18,920
Speaker 1: All right, I'm not even gonna we're gonna take that

1124
00:57:19,000 --> 00:57:24,199
out Brandy, because it's only good if he's up on it.

1125
00:57:24,840 --> 00:57:26,960
But I'll tell you while we're in an edit point. Okay,

1126
00:57:27,239 --> 00:57:31,320
it's basically a way that instead of doing regular rendering,

1127
00:57:32,480 --> 00:57:37,840
you can, oh, you know, like Gaussian blurring. He basically

1128
00:57:37,880 --> 00:57:45,840
create these splats of starting with low resolution detail and

1129
00:57:45,880 --> 00:57:51,440
then getting higher resolution over them, and for some way

1130
00:57:51,599 --> 00:57:54,559
you can do like sixty frames per second rendering of

1131
00:57:54,599 --> 00:57:58,440
a model in real time. Wow, And it's really amazing.

1132
00:57:58,599 --> 00:58:03,320
So yeah, go look that Upusian splatting, Gaussian slat latti NG.

1133
00:58:03,760 --> 00:58:06,400
There's some great demos out there, but it's coming. It's

1134
00:58:06,400 --> 00:58:07,800
a technology that's coming.

1135
00:58:07,599 --> 00:58:09,400
Speaker 3: That sounded like something I needed a towel for.

1136
00:58:09,960 --> 00:58:13,559
Speaker 1: Absolutely, you will you will need a towel when you

1137
00:58:13,639 --> 00:58:17,239
did this stuff. All right, So what haven't we talked

1138
00:58:17,239 --> 00:58:20,400
about before you before we wrap up here, anything else?

1139
00:58:20,719 --> 00:58:24,360
Speaker 3: I the philosophical side of YP and VOC is so important,

1140
00:58:25,079 --> 00:58:27,760
Like because I took a little bit of time after

1141
00:58:27,840 --> 00:58:30,880
doing after making all these wrapper libraries you know, around

1142
00:58:30,920 --> 00:58:34,519
the around NDI, around n Bank, even starting on doing

1143
00:58:34,559 --> 00:58:38,960
rapper libraries around Apple's Video Toolbox, which that's their hardware

1144
00:58:39,000 --> 00:58:44,360
and code. By the way, the Apple silicon for doing

1145
00:58:44,760 --> 00:58:47,400
hardware encode and decode of H two sixty four, two

1146
00:58:47,440 --> 00:58:50,360
sixty five and AVY one is like worth the price

1147
00:58:50,400 --> 00:58:52,800
of admission of having the burden of voting a Mac.

1148
00:58:53,400 --> 00:58:55,599
It's just those chips are insanely good.

1149
00:58:55,840 --> 00:58:57,480
Speaker 1: Mm hmm, even on a MacBook.

1150
00:58:57,599 --> 00:59:00,719
Speaker 3: Yeah, on even on a base M one, yea, even

1151
00:59:00,760 --> 00:59:03,679
on a base M one MacBook Air. It's unbelievable the

1152
00:59:03,679 --> 00:59:06,239
amount of horsepower you get out of that machine. Yeah, yeah,

1153
00:59:06,280 --> 00:59:08,599
it's it's just unbelievable. It's just unfortunate that it's a Mac.

1154
00:59:08,960 --> 00:59:11,760
Speaker 2: Yeah, but any of those all those m chips are extraordinary.

1155
00:59:11,880 --> 00:59:12,400
Yeah they are.

1156
00:59:12,760 --> 00:59:16,719
Speaker 3: Yeah, But the philosophical importance of why P and voke

1157
00:59:16,880 --> 00:59:20,039
is such an awesome technology, why it's underrated is because

1158
00:59:20,440 --> 00:59:22,880
say I'm in Java land and I wanted to call

1159
00:59:22,920 --> 00:59:26,800
into a unmanaged library. Their story has gotten a little

1160
00:59:26,800 --> 00:59:29,880
bit better, but you are still needing to write an

1161
00:59:30,000 --> 00:59:34,400
unmanaged wrapper that your Java library can call into. So

1162
00:59:34,559 --> 00:59:37,159
think about the process. I want to call the Nvidia

1163
00:59:37,239 --> 00:59:41,599
API from Java, I need to write an intermediary layer

1164
00:59:42,039 --> 00:59:46,079
in C that I can then call from Java in

1165
00:59:46,199 --> 00:59:47,360
order to do my P and voke.

1166
00:59:47,880 --> 00:59:48,119
Speaker 2: Yeah.

1167
00:59:48,880 --> 00:59:51,480
Speaker 3: Whereas with dot net, I, as long as I get

1168
00:59:51,480 --> 00:59:53,199
the function signature is right, and as long as I

1169
00:59:53,199 --> 00:59:56,920
annotate everything correctly, the compiler in the back end figures

1170
00:59:56,960 --> 00:59:58,039
all that stuff out for me.

1171
00:59:58,559 --> 00:59:59,000
Speaker 1: Mm hmm.

1172
00:59:59,440 --> 01:00:01,719
Speaker 3: So what you to take, Like you could literally take,

1173
01:00:02,079 --> 01:00:04,400
and I've done this with a couple of APIs. Take

1174
01:00:04,440 --> 01:00:06,920
the C header file for you know, an SDK of

1175
01:00:06,960 --> 01:00:10,159
some sort, put it into chat GPT. Say I need

1176
01:00:10,199 --> 01:00:11,199
P and vote calls for this.

1177
01:00:11,719 --> 01:00:14,320
Speaker 1: I was gonna suggest that, yep, And it's exactly what

1178
01:00:14,360 --> 01:00:15,320
I was gonna do.

1179
01:00:15,679 --> 01:00:18,440
Speaker 3: Yeah, and bam, You've now got a complete wrapper for

1180
01:00:18,519 --> 01:00:19,840
any of this stuff chat.

1181
01:00:19,880 --> 01:00:24,199
Speaker 1: GPT is great for transforming something into something else.

1182
01:00:24,440 --> 01:00:24,639
Speaker 3: Yeah.

1183
01:00:24,800 --> 01:00:25,159
Speaker 2: Yeah.

1184
01:00:25,199 --> 01:00:27,920
Speaker 3: But the reason this is really cool is think about

1185
01:00:27,920 --> 01:00:30,639
what we've got here. Think about the original design goal

1186
01:00:30,679 --> 01:00:34,119
of the C language. We wanted to have portable code

1187
01:00:34,840 --> 01:00:36,960
because we had all of these different architectures, they all

1188
01:00:36,960 --> 01:00:40,960
operated differently. We wanted we wanted to have encapsuley essentially

1189
01:00:41,000 --> 01:00:43,840
our logic into a higher level language that human beings

1190
01:00:43,880 --> 01:00:47,000
can understand, because let's face it, you know, looking at

1191
01:00:47,000 --> 01:00:49,519
a line that says tax, what the hell does that do?

1192
01:00:50,400 --> 01:00:50,599
Speaker 2: Right?

1193
01:00:51,039 --> 01:00:54,519
Speaker 3: But if you look at you know, say, uh, you know,

1194
01:00:55,239 --> 01:00:58,079
frame rate equals sixty. Oh okay, I have a general

1195
01:00:58,119 --> 01:01:00,599
idea that I'm setting a frame rate variable that represents

1196
01:01:00,599 --> 01:01:02,960
the frame rate of some operation, and that is equal

1197
01:01:02,960 --> 01:01:05,480
to the value sixty. I, as a human can understand that.

1198
01:01:06,440 --> 01:01:08,440
The problem with the problem, I would say with C,

1199
01:01:08,599 --> 01:01:11,039
maybe not even the problem, but just the limitation with

1200
01:01:11,119 --> 01:01:13,519
C is because it is such a low level language,

1201
01:01:13,639 --> 01:01:16,760
and the design goals of it were to balance out

1202
01:01:17,360 --> 01:01:21,599
the raw hardware speed with a bit of human creature comfort.

1203
01:01:22,199 --> 01:01:25,400
You don't have a whole lot of safeties there. We

1204
01:01:25,480 --> 01:01:27,679
try to rectify that a little bit with C plus

1205
01:01:27,719 --> 01:01:30,800
plus but that is a whole mess that I don't

1206
01:01:30,840 --> 01:01:32,639
even want to talk about. I've done enough C plus

1207
01:01:32,639 --> 01:01:35,280
plus CLI that it makes me hurt. I still have

1208
01:01:35,360 --> 01:01:36,440
nightmares from those days.

1209
01:01:36,679 --> 01:01:39,119
Speaker 1: It hurts. It hurts my brain just thinking about it.

1210
01:01:39,159 --> 01:01:39,320
Speaker 3: Oh.

1211
01:01:39,320 --> 01:01:41,199
Speaker 1: I think Kate Gregory is the only one that actually

1212
01:01:41,280 --> 01:01:43,039
enjoys writing C plus plus Kate.

1213
01:01:43,199 --> 01:01:47,079
Speaker 3: Kate Gregory is a champion. She she's like, the fact

1214
01:01:47,079 --> 01:01:49,599
that she can make that stuff work is just I've

1215
01:01:50,159 --> 01:01:53,400
infinite respect just yea too. I can listen to her

1216
01:01:53,440 --> 01:01:55,039
speak for days on that stuff.

1217
01:01:55,079 --> 01:01:56,800
Speaker 2: But you've also found a way to get the kind

1218
01:01:56,840 --> 01:01:59,599
of farms we're talking that we need here to handle

1219
01:01:59,679 --> 01:02:02,599
multiple streams and not need to live in C plus

1220
01:02:02,599 --> 01:02:03,400
plus line.

1221
01:02:03,239 --> 01:02:06,400
Speaker 3: Yeah, or or just live in seaaland when you need

1222
01:02:06,400 --> 01:02:09,039
to for those for them, it's the application, because like

1223
01:02:09,079 --> 01:02:11,840
do we need to write every last I'll give you

1224
01:02:11,840 --> 01:02:15,480
an example for my multiview. I've got a web api

1225
01:02:16,079 --> 01:02:19,079
h gdp api that you can use to make to

1226
01:02:19,199 --> 01:02:22,039
change everything about the multiview. If you want to assign sources,

1227
01:02:22,119 --> 01:02:24,639
if you want to move boxes on the screen around

1228
01:02:25,480 --> 01:02:28,000
you know, why do I need to write that in

1229
01:02:28,119 --> 01:02:31,320
C plus plus right? Like, there's no good reason for.

1230
01:02:31,239 --> 01:02:33,920
Speaker 2: It, no reason, and plenty of reasons not.

1231
01:02:33,960 --> 01:02:37,559
Speaker 3: To, Yeah, exactly, not least of which are security, right,

1232
01:02:38,599 --> 01:02:39,480
Like how it's just.

1233
01:02:39,480 --> 01:02:43,239
Speaker 2: The fragility, the maintainability, like it's all those things.

1234
01:02:43,360 --> 01:02:47,840
Speaker 1: Yeah, So nothing else today, kids, you've learned that p

1235
01:02:48,039 --> 01:02:50,840
and voke is way more powerful than you thought it

1236
01:02:50,880 --> 01:02:53,079
was ever going to be back when you were calling

1237
01:02:53,119 --> 01:02:56,960
the Windows API from vb net or c sharp, you know,

1238
01:02:57,039 --> 01:03:02,119
one point zero. Because now the platform have expanded and

1239
01:03:02,159 --> 01:03:04,920
we still have p and vogue, so we can take

1240
01:03:04,960 --> 01:03:07,840
our dot net code and go anywhere and get to

1241
01:03:07,880 --> 01:03:11,960
the native hardware. That's that's the philosophy that Elias is

1242
01:03:11,960 --> 01:03:14,920
talking about here, that we have to get out of

1243
01:03:14,960 --> 01:03:18,760
Windows mode in dot net, yes, and into cross platform mode.

1244
01:03:18,800 --> 01:03:20,159
And this is just one example of that.

1245
01:03:20,199 --> 01:03:23,599
Speaker 3: Well here's one last point. I just thought of this,

1246
01:03:23,760 --> 01:03:25,679
and this is like a penny drop moment for me.

1247
01:03:26,559 --> 01:03:29,719
Imagine you've got some legacy code and I'm talking like

1248
01:03:30,159 --> 01:03:32,039
the author, and I've been in the scenario where it's

1249
01:03:32,039 --> 01:03:35,199
like literally the author of that original code has passed on,

1250
01:03:35,599 --> 01:03:37,519
so we can't even go drag them out of drag

1251
01:03:37,559 --> 01:03:39,599
them out of retirement and ask them like what does

1252
01:03:39,639 --> 01:03:43,159
this do maybe we've lost the source code, but we've

1253
01:03:43,199 --> 01:03:46,039
got this, you know, but we've got this wrapped into

1254
01:03:46,239 --> 01:03:48,880
a library of some sort, or we can get close enough, right,

1255
01:03:49,480 --> 01:03:52,239
And we don't want to rewrite this old piece of

1256
01:03:52,239 --> 01:03:54,000
logic that lives in a c library, lives in an

1257
01:03:54,039 --> 01:03:57,880
unmanaged library, but we need to use it for some reason. Okay, cool,

1258
01:03:58,639 --> 01:04:00,960
we can write a if you can write C sharp,

1259
01:04:01,239 --> 01:04:04,199
you can call into that existing DLL and that can

1260
01:04:04,280 --> 01:04:06,519
just live on as a rapper. And because we can

1261
01:04:06,519 --> 01:04:09,840
target X eighty six thirty two, X eighty six sixty four,

1262
01:04:10,039 --> 01:04:12,880
ARM thirty two, ARM sixty four whatever platforms dot Net

1263
01:04:12,920 --> 01:04:15,719
will compile down to. This is now a means of

1264
01:04:15,840 --> 01:04:20,519
preserving and carrying forward that old legacy code, you know,

1265
01:04:20,760 --> 01:04:23,679
in a modern language with all the modern creature comforts.

1266
01:04:24,039 --> 01:04:26,320
Speaker 2: And if you want to bring cameras into your software,

1267
01:04:26,599 --> 01:04:29,400
use POE cameras. Your life will be simpler. Oh yes,

1268
01:04:29,480 --> 01:04:32,559
please do no custom hardware. It's just on the network.

1269
01:04:32,599 --> 01:04:34,960
It has an IP address. You'll be fine.

1270
01:04:35,039 --> 01:04:38,719
Speaker 1: Mm hmm, all right, And NDI is your uncle Elias.

1271
01:04:38,800 --> 01:04:40,880
Thank you so much. This has been a great talk

1272
01:04:41,360 --> 01:04:45,199
for me personally, and I hope everyone else that's interested

1273
01:04:45,199 --> 01:04:46,199
in audio and videos.

1274
01:04:46,239 --> 01:04:48,440
Speaker 3: Thank you, it's been an absolute pleasure. I think I'm

1275
01:04:48,480 --> 01:04:49,960
going to go off and see if I can adjust

1276
01:04:49,960 --> 01:04:51,159
my sound last settings.

1277
01:04:51,519 --> 01:04:56,760
Speaker 1: Yeah, playjazz dot mid while you're at playjazz dot mid.

1278
01:04:57,880 --> 01:05:20,840
All right, We'll see you next time on dot dot net.

1279
01:05:20,960 --> 01:05:23,840
Rocks is brought to you by Franklin's Net and produced

1280
01:05:23,880 --> 01:05:27,719
by Pop Studios, a full service audio, video and post

1281
01:05:27,719 --> 01:05:31,880
production facility located physically in New London, Connecticut, and of

1282
01:05:31,920 --> 01:05:36,840
course in the cloud online at pwop dot com. Visit

1283
01:05:36,880 --> 01:05:39,000
our website at d O T N E t R

1284
01:05:39,039 --> 01:05:43,000
O c k S dot com for RSS feeds, downloads,

1285
01:05:43,119 --> 01:05:46,800
mobile apps, comments, and access to the full archives going

1286
01:05:46,840 --> 01:05:50,039
back to show number one, recorded in September two.

1287
01:05:49,920 --> 01:05:50,480
Speaker 2: Thousand and two.

1288
01:05:51,159 --> 01:05:53,480
Speaker 1: And make sure you check out our sponsors. They keep

1289
01:05:53,559 --> 01:05:56,760
us in business. Now go write some code. See you

1290
01:05:56,760 --> 01:06:02,800
next time. You got Jack Dully to see A summer

1291
01:06:03,480 --> 01:06:08,440
time that means is home than my Texas a lie

1292
01:06:08,679 --> 01:06:09,320
fresival

