From 178bbb677b76216ec0cbec207d1a75a43d169c60 Mon Sep 17 00:00:00 2001 From: Dokugogagoji_cp Date: Sat, 2 Aug 2008 20:11:44 +0000 Subject: [PATCH] progress on ak4531 dac --- .../Audio/Components/DACEntity.cs | 2 +- .../Devices/ES1370/Components/DACak4531.cs | 16 ++++++++-- .../Audio/Devices/ES1370/ES1370.cs | 20 ++++++++---- .../Audio/Devices/GenericSoundCard.cs | 1 - .../Audio/Managers/DACManager.cs | 16 +++++++--- .../Cosmos/Cosmos.Hardware/Audio/PCMStream.cs | 5 +++ source/DokuTest/Sample sound/SoundSamples.cs | 32 +++++++++++++++---- 7 files changed, 70 insertions(+), 22 deletions(-) diff --git a/source/Cosmos/Cosmos.Hardware/Audio/Components/DACEntity.cs b/source/Cosmos/Cosmos.Hardware/Audio/Components/DACEntity.cs index 1b28a5422..fe78168d8 100644 --- a/source/Cosmos/Cosmos.Hardware/Audio/Components/DACEntity.cs +++ b/source/Cosmos/Cosmos.Hardware/Audio/Components/DACEntity.cs @@ -7,6 +7,6 @@ namespace Cosmos.Hardware.Audio.Devices { public class DACEntity { - public DACEntity(byte dacAddr, byte dacSizeAddr) { } + public DACEntity() { } } } diff --git a/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/Components/DACak4531.cs b/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/Components/DACak4531.cs index 85b4c7804..b71bebb50 100644 --- a/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/Components/DACak4531.cs +++ b/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/Components/DACak4531.cs @@ -7,7 +7,7 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Components { class DACak4531 : DACEntity { - public DACak4531(byte dacAddr,byte dacSizeAddr) : base(dacAddr, dacSizeAddr) { } + public DACak4531() : base() { } public enum Bit : byte { @@ -16,7 +16,19 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Components LeftVoiceVol= 0x02, // channel volume left RightVoiceVol = 0x03, //channel volume right LeftFMVol = 0x04, //FM volume left - RightFMVol = 0x05//FM volume right + RightFMVol = 0x05,//FM volume right + LeftCDVol = 0x06, //CD Volume left + RightCDVol = 0x07, + MonoLeft = 0x0c, //Mono volume left + MonoRight= 0x0d, //Mono volume right + MonoOutVol= 0x0f, //Mono out volume + Sw1Out=0x10, //Mixer output chooser 1 + Sw2Out = 0x11, //Mixer output chooser 2 + Sw1In = 0x12, + Sw2In = 0x13, + Reset=0x16, + Clock=0x17, + Ad=0x18 } } } diff --git a/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/ES1370.cs b/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/ES1370.cs index d62182276..4f0440149 100644 --- a/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/ES1370.cs +++ b/source/Cosmos/Cosmos.Hardware/Audio/Devices/ES1370/ES1370.cs @@ -20,7 +20,10 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370 private UARTInterfaceRegister uir; public int[] FixedRatesSupported={5512, 11025, 22050, 44100}; public const int SRClock = 1411200; - + public const int minClockDen=29; + public const int maxClockDen=353; + public const int clockStep=1; + public ES1370(PCIDevice device) : base(device) { @@ -28,9 +31,10 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370 sir = (SerialInterfaceRegister.Load(getMemReference())); uir = (UARTInterfaceRegister.Load(getMemReference())); cr=(ControlRegister.Load(getMemReference())); - dacs.Add(new DACManager(new DACak4531((byte)MainRegister.Bit.Dac1FrameAddr, (byte)MainRegister.Bit.Dac1FrameSize))); - dacs.Add(new DACManager(new DACak4531((byte)MainRegister.Bit.Dac2FrameAddr, (byte)MainRegister.Bit.Dac2FrameSize))); - + dacs.Add(new DACManager(new DACak4531(), cr.DAC1Enabled,(byte)MainRegister.Bit.Dac1FrameAddr, (byte)MainRegister.Bit.Dac1FrameSize)); + dacs.Add(new DACManager(new DACak4531(), cr.DAC2Enabled, (byte)MainRegister.Bit.Dac2FrameAddr, (byte)MainRegister.Bit.Dac2FrameSize)); + foreach (var dac in dacs.ToArray()) + preparePlayBackOnDac(dac); } /// /// Retrieve all Ensoniq AudioPCI 1370 cards found on computer. @@ -121,9 +125,13 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370 } #endregion - public void prepareStreamPlayBack(PCMStream pcmStream) +#region I/O Helper routine + private void setDataOnDACCodec(DACManager dacManager){ } +#endregion + private void preparePlayBackOnDac(DACManager dacManager) { - + bool state = dacManager.setDACStateEnabled(true); + Console.WriteLine("State: " + state); } } diff --git a/source/Cosmos/Cosmos.Hardware/Audio/Devices/GenericSoundCard.cs b/source/Cosmos/Cosmos.Hardware/Audio/Devices/GenericSoundCard.cs index 7182d7466..131d3d32e 100644 --- a/source/Cosmos/Cosmos.Hardware/Audio/Devices/GenericSoundCard.cs +++ b/source/Cosmos/Cosmos.Hardware/Audio/Devices/GenericSoundCard.cs @@ -14,7 +14,6 @@ namespace Cosmos.Hardware.Audio.Devices protected List adcs; protected List uarts; - #endregion public GenericSoundCard(PCIDevice device){ diff --git a/source/Cosmos/Cosmos.Hardware/Audio/Managers/DACManager.cs b/source/Cosmos/Cosmos.Hardware/Audio/Managers/DACManager.cs index 0678e4e71..48793e0f0 100644 --- a/source/Cosmos/Cosmos.Hardware/Audio/Managers/DACManager.cs +++ b/source/Cosmos/Cosmos.Hardware/Audio/Managers/DACManager.cs @@ -9,15 +9,21 @@ namespace Cosmos.Hardware.Audio.Managers public class DACManager { private DACEntity dacEntity; - private long dataSize; - public DACManager(DACEntity dacEntity) + private byte dacAddr; + private byte dacSizeAddr; + bool dacEnabled; + public DACManager(DACEntity dacEntity, bool dacEnabled , byte dacAddr, byte dacSizeAddr) { this.dacEntity = dacEntity; - this.dataSize = 0; + this.dacAddr = dacAddr; + this.dacSizeAddr = dacSizeAddr; + this.dacEnabled = dacEnabled; } - protected void prepareDACStreamPlayBack(PCMStream pcmStream, int rate) - { + public bool setDACStateEnabled(bool state) + { + dacEnabled = state; + return dacEnabled; } } } diff --git a/source/Cosmos/Cosmos.Hardware/Audio/PCMStream.cs b/source/Cosmos/Cosmos.Hardware/Audio/PCMStream.cs index 6b532fdd5..3aa2cf4c8 100644 --- a/source/Cosmos/Cosmos.Hardware/Audio/PCMStream.cs +++ b/source/Cosmos/Cosmos.Hardware/Audio/PCMStream.cs @@ -7,6 +7,11 @@ namespace Cosmos.Hardware.Audio.Devices { public class PCMStream { + int rate; + int[] data; + public PCMStream(int rate, int[] data) + { + } } } diff --git a/source/DokuTest/Sample sound/SoundSamples.cs b/source/DokuTest/Sample sound/SoundSamples.cs index 23024a04d..c21334d51 100644 --- a/source/DokuTest/Sample sound/SoundSamples.cs +++ b/source/DokuTest/Sample sound/SoundSamples.cs @@ -6,13 +6,31 @@ using System.Text; namespace DokuTest.Sample_sound { public static class SoundSamples - {/* - uint rate; - uint channels; - uint freq; + { - public SoundSamples(){} - public class sineSignal { } - */ + public static Cosmos.Hardware.Audio.Devices.PCMStream generateSineWaveForm(double freq, int rate, int count, int sampleSize, int[] channelsList, int period, int nPeriods, double phase) + { + double max_phase = 1.0 / freq; + double step = 1.0 / (double)rate; + double res; + float fres; + //PCMStream pcmStream = new PCMStream(); + List frames = new List(); + + int ind_chan; + while (count-- > 0) + {/* + for (ind_chan = 0; ind_chan < nChannels; ind_chan++) + { + if (sampleSize == 8) + { + if (chn == channel) + { + } + } + }*/ + } + return null; + } } }