Commit 6515cea0 authored by Christian Fibich's avatar Christian Fibich
Browse files

More correct ADSR mixing

parent c6552f9a
......@@ -2,21 +2,25 @@ module mixer (input wire clock, input wire reset,
input wire ce, input wire [15:0] tone,
input wire [15:0] envelope, output wire [15:0] out);
reg [31:0] sample;
wire [31:0] sample_next;
reg [15:0] sample;
wire [15:0] inv;
wire [31:0] scale;
wire [15:0] sample_next;
assign inv = (tone[15:8] != 8'b0) ? (tone[15:0] - 16'h8000) : (16'h8000 - tone[15:0]);
assign scale = {16'b0, inv} * {16'b0, envelope[15:0]};
assign sample_next = (tone[15:8] != 8'b0) ? (scale[31:16] + 16'h8000) : (16'h8000 - scale[31:16]);
assign sample_next = tone[15:0] * envelope[15:0];
always @ (posedge clock or posedge reset)
begin
if (reset)
sample <= 32'b0;
sample <= 16'b0;
else if (ce) begin
sample <= sample_next;
//$display("%d", sample[31:16]);
end
end
assign out = sample[31:16];
assign out = sample;
endmodule
module hx8k_audio_top #(parameter NUM_VOICES = 8, parameter WAVEFORM = 0) ( input clock_in,
module hx8k_audio_top #(parameter NUM_VOICES = 6, parameter WAVEFORM = 0) ( input clock_in,
input rx,
output tx,
output [7:0] led,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment