Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions native-bridge/src/protocol/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ impl BridgeServer {
} else {
empty_read_counter += 1;
}
} else if loop_counter % 1000 == 0 {
warn!("[Server] Audio engine not running (loop {})", loop_counter);
} else if loop_counter == 5000 {
// Only log once after ~5 seconds if audio hasn't started yet
info!("[Server] Waiting for audio engine to start...");
}
}

Expand Down
19 changes: 17 additions & 2 deletions src/components/daw/user-track-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export function UserTrackHeader({
setTrackMuted,
setTrackSolo,
setTrackVolume,
setTrackPan,
setTrackArmed,
updateTrack,
} = useUserTracksStore();
Expand Down Expand Up @@ -486,9 +487,10 @@ export function UserTrackHeader({
</div>
</div>

{/* Expanded Controls - Volume */}
{/* Expanded Controls - Volume & Pan */}
{isExpanded && (
<div className="px-3 pb-2 pt-1 border-t border-gray-200 dark:border-white/5">
<div className="px-3 pb-2 pt-1 border-t border-gray-200 dark:border-white/5 space-y-1.5">
{/* Volume */}
<div className="flex items-center gap-2">
<Volume2 className="w-3 h-3 text-gray-500 dark:text-zinc-500 shrink-0" />
<Fader
Expand All @@ -500,6 +502,19 @@ export function UserTrackHeader({
{Math.round(track.volume * 100)}%
</span>
</div>
{/* Pan */}
<div className="flex items-center gap-2">
<span className="text-[9px] text-gray-500 dark:text-zinc-500 w-3 text-center shrink-0">L</span>
<Fader
value={(track.pan + 1) / 2}
onChange={(v) => setTrackPan(track.id, v * 2 - 1)}
className="flex-1"
/>
<span className="text-[9px] text-gray-500 dark:text-zinc-500 w-3 text-center shrink-0">R</span>
<span className="text-[9px] text-gray-500 dark:text-zinc-500 w-6 text-right">
{track.pan === 0 ? 'C' : track.pan < 0 ? `L${Math.round(Math.abs(track.pan) * 100)}` : `R${Math.round(track.pan * 100)}`}
</span>
</div>
</div>
)}

Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useTrackAudioSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface TrackSyncState {
isMuted: boolean;
isSolo: boolean;
volume: number;
pan: number;
inputGainDb: number;
monitoringEnabled: boolean;
monitoringVolume: number;
Expand Down Expand Up @@ -73,6 +74,7 @@ export function useTrackAudioSync(currentUserId: string | undefined) {
isMuted: isEffectivelyMuted,
isSolo: track.isSolo,
volume: track.volume,
pan: track.pan ?? 0,
inputGainDb: track.audioSettings.inputGain || 0,
monitoringEnabled: directMonitoring,
monitoringVolume: track.audioSettings.monitoringVolume ?? 1,
Expand All @@ -85,6 +87,7 @@ export function useTrackAudioSync(currentUserId: string | undefined) {
isMuted: isEffectivelyMuted,
isSolo: track.isSolo,
volume: track.volume,
pan: track.pan ?? 0,
inputGainDb: track.audioSettings.inputGain || 0,
monitoringEnabled: directMonitoring,
monitoringVolume: track.audioSettings.monitoringVolume ?? 1,
Expand Down Expand Up @@ -151,6 +154,7 @@ export function useTrackAudioSync(currentUserId: string | undefined) {
isMuted: isEffectivelyMuted,
isSolo: track.isSolo,
volume: track.volume,
pan: track.pan ?? 0,
inputGainDb: track.audioSettings.inputGain || 0,
monitoringEnabled: track.audioSettings.directMonitoring ?? true,
monitoringVolume: track.audioSettings.monitoringVolume ?? 1,
Expand Down Expand Up @@ -206,6 +210,7 @@ export function useTrackAudioSync(currentUserId: string | undefined) {
lastState.isMuted !== currentState.isMuted ||
lastState.isSolo !== currentState.isSolo ||
lastState.volume !== currentState.volume ||
lastState.pan !== currentState.pan ||
lastState.inputGainDb !== currentState.inputGainDb ||
lastState.monitoringEnabled !== currentState.monitoringEnabled ||
lastState.monitoringVolume !== currentState.monitoringVolume;
Expand All @@ -216,6 +221,7 @@ export function useTrackAudioSync(currentUserId: string | undefined) {
isMuted: currentState.isMuted,
isSolo: currentState.isSolo,
volume: currentState.volume,
pan: currentState.pan,
inputGainDb: currentState.inputGainDb,
monitoringEnabled: currentState.monitoringEnabled,
monitoringVolume: currentState.monitoringVolume,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/audio/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ export class NativeBridge {
isMuted?: boolean;
isSolo?: boolean;
volume?: number;
pan?: number;
inputGainDb?: number;
monitoringEnabled?: boolean;
monitoringVolume?: number;
Expand All @@ -581,6 +582,7 @@ export class NativeBridge {
isMuted: state.isMuted,
isSolo: state.isSolo,
volume: state.volume,
pan: state.pan,
inputGainDb: state.inputGainDb,
monitoringEnabled: state.monitoringEnabled,
monitoringVolume: state.monitoringVolume,
Expand Down
24 changes: 23 additions & 1 deletion src/stores/user-tracks-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { UserTrack, TrackAudioSettings, ExtendedEffectsChain, InputChannelC
import { DEFAULT_FULL_EFFECTS } from '@/lib/audio/effects-defaults';
import { EFFECT_PRESETS } from '@/lib/audio/effects/presets';
import { GUITAR_PRESETS } from '@/lib/audio/effects/guitar';
import { nativeBridge } from '@/lib/audio/native-bridge';

// Track color palette - exported for use in color picker
export const TRACK_COLORS = [
Expand Down Expand Up @@ -94,6 +95,7 @@ interface UserTracksState {
setTrackMuted: (trackId: string, muted: boolean) => void;
setTrackSolo: (trackId: string, solo: boolean) => void;
setTrackVolume: (trackId: string, volume: number) => void;
setTrackPan: (trackId: string, pan: number) => void;
setTrackArmed: (trackId: string, armed: boolean) => void;
setTrackRecording: (trackId: string, recording: boolean) => void;
setTrackStream: (trackId: string, stream: MediaStream | undefined) => void;
Expand Down Expand Up @@ -162,6 +164,7 @@ export const useUserTracksStore = create<UserTracksState>()(
isMuted: false,
isSolo: false,
volume: 1,
pan: 0, // Center
isArmed: false, // New tracks are not armed by default
isRecording: false,
createdAt: Date.now(),
Expand Down Expand Up @@ -203,6 +206,7 @@ export const useUserTracksStore = create<UserTracksState>()(
isMuted: false,
isSolo: false,
volume: 1,
pan: 0, // Center
isArmed: false,
isRecording: false,
createdAt: Date.now(),
Expand Down Expand Up @@ -332,6 +336,10 @@ export const useUserTracksStore = create<UserTracksState>()(
activePreset: undefined, // Clear preset when manually editing
},
});

// Send effects to native bridge for real-time processing
nativeBridge.updateEffects(trackId, newEffects);

return { tracks };
}),

Expand All @@ -348,6 +356,10 @@ export const useUserTracksStore = create<UserTracksState>()(
channelConfig,
},
});

// Send channel config to native bridge
nativeBridge.setChannelConfig(channelConfig);

return { tracks };
}),

Expand Down Expand Up @@ -393,14 +405,19 @@ export const useUserTracksStore = create<UserTracksState>()(
if (!preset) return state;

const tracks = new Map(state.tracks);
const newEffects = JSON.parse(JSON.stringify(preset.effects)); // Deep clone
tracks.set(trackId, {
...track,
audioSettings: {
...track.audioSettings,
effects: JSON.parse(JSON.stringify(preset.effects)), // Deep clone
effects: newEffects,
activePreset: presetId,
},
});

// Send effects to native bridge
nativeBridge.updateEffects(trackId, newEffects);

return { tracks };
}),

Expand Down Expand Up @@ -438,12 +455,17 @@ export const useUserTracksStore = create<UserTracksState>()(
activePreset: presetId,
},
});

// Send effects to native bridge
nativeBridge.updateEffects(trackId, newEffects);

return { tracks };
}),

setTrackMuted: (trackId, muted) => get().updateTrack(trackId, { isMuted: muted }),
setTrackSolo: (trackId, solo) => get().updateTrack(trackId, { isSolo: solo }),
setTrackVolume: (trackId, volume) => get().updateTrack(trackId, { volume }),
setTrackPan: (trackId, pan) => get().updateTrack(trackId, { pan: Math.max(-1, Math.min(1, pan)) }),
setTrackArmed: (trackId, armed) => get().updateTrack(trackId, { isArmed: armed }),
setTrackRecording: (trackId, recording) => get().updateTrack(trackId, { isRecording: recording }),
setTrackStream: (trackId, stream) => get().updateTrack(trackId, { stream }),
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export interface UserTrack {
isMuted: boolean;
isSolo: boolean;
volume: number;
pan: number; // -1 (full left) to 1 (full right), 0 = center
isArmed: boolean; // Ready to record
isRecording: boolean;
stream?: MediaStream;
Expand Down
Loading