@@ -76,7 +76,7 @@ class MetalOrbRenderer: NSObject, MTKViewDelegate {
7676
7777 private var uniforms = OrbUniforms ( )
7878 private var randomOffsets : [ Float ] = [ ]
79- private var currentAgentState : AgentState = . unknown
79+ private var currentAgentState : VisualizerAgentState = . unknown
8080
8181 // MARK: - Init
8282
@@ -104,7 +104,7 @@ class MetalOrbRenderer: NSObject, MTKViewDelegate {
104104 uniforms. outputVolume = max ( 0 , min ( 1 , output) )
105105 }
106106
107- func updateAgentState( _ state: AgentState ) {
107+ func updateAgentState( _ state: VisualizerAgentState ) {
108108 // No longer inverting colors for thinking state
109109 uniforms. inverted = 0
110110 currentAgentState = state
@@ -161,19 +161,17 @@ class MetalOrbRenderer: NSObject, MTKViewDelegate {
161161 // Try to load the Metal library from various sources
162162 var lib : MTLLibrary ?
163163
164- // First try the module bundle (for SwiftPM)
165- #if SWIFT_PACKAGE
166- lib = try ? device. makeDefaultLibrary ( bundle: Bundle . module)
167- #endif
164+ // Try default library first (works when Metal files are properly compiled)
165+ lib = device. makeDefaultLibrary ( )
168166
169- // If not found , try the main bundle
167+ // If that fails , try the class bundle
170168 if lib == nil {
171- lib = try ? device. makeDefaultLibrary ( bundle: . main )
169+ lib = try ? device. makeDefaultLibrary ( bundle: Bundle ( for : type ( of : self ) ) )
172170 }
173171
174- // If still not found, try to create default library
172+ // If not found, try the main bundle
175173 if lib == nil {
176- lib = device. makeDefaultLibrary ( )
174+ lib = try ? device. makeDefaultLibrary ( bundle : . main )
177175 }
178176
179177 guard let library = lib else {
@@ -205,7 +203,7 @@ struct _OrbPlatformView: NSViewRepresentable {
205203 var color2 : Color
206204 var inputVolume : Float
207205 var outputVolume : Float
208- var agentState : AgentState
206+ var agentState : VisualizerAgentState
209207
210208 func makeNSView( context: Context ) -> MTKView {
211209 let view = MTKView ( )
@@ -233,7 +231,7 @@ struct _OrbPlatformView: NSViewRepresentable {
233231 }
234232
235233 final class Coordinator : MetalOrbRenderer {
236- func updateAll( color1: Color , color2: Color , input: Float , output: Float , state: AgentState ) {
234+ func updateAll( color1: Color , color2: Color , input: Float , output: Float , state: VisualizerAgentState ) {
237235 updateColors ( color1: color1, color2: color2)
238236 updateVolumes ( input: input, output: output)
239237 updateAgentState ( state)
@@ -246,7 +244,7 @@ struct _OrbPlatformView: UIViewRepresentable {
246244 var color2 : Color
247245 var inputVolume : Float
248246 var outputVolume : Float
249- var agentState : AgentState
247+ var agentState : VisualizerAgentState
250248
251249 func makeUIView( context: Context ) -> MTKView {
252250 let view = MTKView ( )
@@ -274,7 +272,7 @@ struct _OrbPlatformView: UIViewRepresentable {
274272 }
275273
276274 final class Coordinator : MetalOrbRenderer {
277- func updateAll( color1: Color , color2: Color , input: Float , output: Float , state: AgentState ) {
275+ func updateAll( color1: Color , color2: Color , input: Float , output: Float , state: VisualizerAgentState ) {
278276 updateColors ( color1: color1, color2: color2)
279277 updateVolumes ( input: input, output: output)
280278 updateAgentState ( state)
@@ -288,9 +286,9 @@ public struct Orb: View {
288286 public var color2 : Color
289287 public var inputVolume : Float
290288 public var outputVolume : Float
291- public var agentState : AgentState
289+ public var agentState : VisualizerAgentState
292290
293- public init ( color1: Color , color2: Color , inputVolume: Float , outputVolume: Float , agentState: AgentState = . unknown) {
291+ public init ( color1: Color , color2: Color , inputVolume: Float , outputVolume: Float , agentState: VisualizerAgentState = . unknown) {
294292 self . color1 = color1
295293 self . color2 = color2
296294 self . inputVolume = inputVolume
@@ -303,12 +301,12 @@ public struct Orb: View {
303301 let side = max ( 1 , min ( geo. size. width, geo. size. height) )
304302
305303 // Override input volume to 1.0 when thinking
306- let effectiveInputVolume = agentState == . thinking ? 1.0 : inputVolume
304+ // (This line removed as per instructions)
307305
308306 _OrbPlatformView (
309307 color1: color1,
310308 color2: color2,
311- inputVolume: effectiveInputVolume ,
309+ inputVolume: inputVolume ,
312310 outputVolume: outputVolume,
313311 agentState: agentState
314312 )
@@ -335,7 +333,7 @@ public struct Orb: View {
335333/// ```
336334/// let inputTrack: AudioTrack = ...
337335/// let outputTrack: AudioTrack = ...
338- /// let agentState: AgentState = ...
336+ /// let agentState: VisualizerAgentState = ...
339337/// OrbVisualizer(inputTrack: inputTrack, outputTrack: outputTrack, agentState: agentState)
340338/// ```
341339///
@@ -352,13 +350,13 @@ public struct Orb: View {
352350public struct OrbVisualizer : View {
353351 public let colors : ( Color , Color )
354352
355- private let agentState : AgentState
353+ private let agentState : VisualizerAgentState
356354
357355 @StateObject private var inputProcessor : AudioProcessor
358356 @StateObject private var outputProcessor : AudioProcessor
359357
360358 public init ( inputTrack: AudioTrack ? , outputTrack: AudioTrack ? ,
361- agentState: AgentState = . unknown,
359+ agentState: VisualizerAgentState = . unknown,
362360 colors: ( Color , Color ) = ( Color ( red: 0.793 , green: 0.863 , blue: 0.988 ) ,
363361 Color ( red: 0.627 , green: 0.725 , blue: 0.820 ) ) )
364362 {
@@ -374,8 +372,6 @@ public struct OrbVisualizer: View {
374372 let inputVolume = aggregateVolume ( from: inputProcessor. bands)
375373 let outputVolume = aggregateVolume ( from: outputProcessor. bands)
376374
377- let effectiveInputVolume = agentState == . thinking ? 1.0 : Float ( inputVolume)
378-
379375 Orb ( color1: colors. 0 ,
380376 color2: colors. 1 ,
381377 inputVolume: Float ( inputVolume) ,
@@ -423,7 +419,7 @@ public struct OrbVisualizer: View {
423419struct OrbVisualizer_Previews : PreviewProvider {
424420 struct AnimatedOrbPreview : View {
425421 let isInput : Bool
426- let agentState : AgentState
422+ let agentState : VisualizerAgentState
427423 let colors : ( Color , Color )
428424
429425 @State private var volume : Float = 0.0
0 commit comments