我感兴趣的是如何拍音符(例如A,B,C#等)或和弦(同时多个音符)并将它们写入wav文件.
根据我的理解,每个音符都有一个与之相关的特定频率(对于完美的音高) - 例如A4(中间C以上的A)是440 Hz(完整列表本页下方的2/3 ).
如果我的理解是正确的,那么这个音调是在频域中,所以需要应用它的逆快速傅立叶变换来生成时域等价物吗?
我想知道的是:
谢谢你提供的所有帮助.如果给出代码示例,我使用的是C#,我目前用来创建wav文件的代码如下:
int channels = 1;
int bitsPerSample = 8;
//WaveFile is custom class to create a wav file.
WaveFile file = new WaveFile(channels, bitsPerSample, 11025);
int seconds = 60;
int samples = 11025 * seconds; //Create x seconds of audio
// Sound Data Size = Number Of Channels * Bits Per Sample * Samples
byte[] data = new byte[channels * bitsPerSample/8 * samples];
//Creates a Constant …Run Code Online (Sandbox Code Playgroud) 我用java创建了一个docker镜像,并在图像中使用coppying jar文件.我的Dockerfile是:
FROM anapsix/alpine-java
MAINTAINER myNAME
COPY testprj-1.0-SNAPSHOT.jar /home/testprj-1.0-SNAPSHOT.jar
RUN java -jar /home/testprj-1.0-SNAPSHOT.j
Run Code Online (Sandbox Code Playgroud)
执行以下命令后
docker build -t imageName.
Run Code Online (Sandbox Code Playgroud)
在控制台中,我看到应用程序和everthing的输出很好.但是,当我停止图像时,我不知道如何再次运行图像?执行以下命令时:
docker run -i -t imageName java -jar /home/testprj-1.0-SNAPSHOT.jar
Run Code Online (Sandbox Code Playgroud)
应用程序再次运行,但在我的Dockerfile中我已经写了这个命令.如何在没有此命令的情况下运行映像,应用程序会自动运行
为了彻底解释,这个问题已经彻底改革.
我注意到C#6.0中空传播运算符的限制似乎很差,因为你无法针对已经传播的对象调用属性设置器(尽管你可以针对已经传播的对象调用属性getter) .正如您将从生成的IL (我已反映到C#中)看到的那样,没有任何东西可以限制使用空传播调用属性设置器的能力.
首先,我创建了一个简单的类,包括Java样式的Get/Set方法和具有公共getter/setter访问权限的属性.
public class Person
{
public Person(string name, DateTime birthday)
{
Name = name;
}
public string Name { get; set; }
public void SetName(string name)
{
Name = name;
}
public string GetName()
{
return Name;
}
}
Run Code Online (Sandbox Code Playgroud)
我已经在下面的测试类中测试了空传播的能力.
public class Program
{
public static void Main(string[] args)
{
Person person = new Person("Joe Bloggs", DateTime.Parse("01/01/1991"));
// This line doesn't work - see documented error below
person?.Name = "John Smith"; …Run Code Online (Sandbox Code Playgroud) 我有一个包含双精度的csv字符串(例如"0.3,0.4,0.3"),我希望能够输出一个包含这些数字累积和的双数组(例如[0.3,0.7,1.0]).
到目前为止,我有
double[] probabilities = textBox_f.Text.Split(new char[]{','}).Select(s => double.Parse(s)).ToArray();
它将数字作为数组给出,但不是数字的累积和.
有没有办法继续这个表达式来获得我想要的东西,还是我需要使用迭代从我已经拥有的数组创建一个新的数组?
OR 表达式如何与选择器和标签一起使用?
selector:
app: myapp
tier: frontend
Run Code Online (Sandbox Code Playgroud)
以上匹配标签app==myapp AND 的 pod tier=frontend。
但是OR表达式可以用吗?
app==myapp 或 tier=frontend?
这有点复杂,但我会尽力解释清楚.
我有一个用于公共代码组件的类库; 我尝试制作一些通用的ConfigurationHandler基类,以简化创建自定义配置节,集合和元素.
我最终得到的是:
本ConfigurationSectionBase类是通用的,以TConfElementCollection As {ConfigurationElementCollection, New}作为一种约束.
这个ConfigurationSectionBase类包含一个Public MustOverride Property Collection As TConfElementCollection.
我们的想法是,在使用类库的项目中,他们只需要覆盖集合并使用<ConfigurationProperty("CollectionName")>属性进行装饰,例如:
<ConfigurationProperty("CollectionName")>
Public Overrides Property Collection As DerivedConfigurationElementCollection
Get
Return TryCast(Me("CollectionName"), DerivedConfigurationElementCollection)
End Get
Set(value As DerivedConfigurationElementCollection)
Me("CollectionName") = value
End Set
End Property
Run Code Online (Sandbox Code Playgroud)
这工作正常 - 在使用应用程序中我可以创建该部分,然后在我可以调用的配置处理程序类中
Dim section As DerivedSection = (TryCast(Config.GetSection("DerivedSection"), DerivedSection))
Dim coll as DerivedConfigurationElementCollection = section?.Collection
Run Code Online (Sandbox Code Playgroud)
那么,我的下一个想法是,为什么不抽象Config Handler类,并将其移到基类中?
事实证明这更复杂,但我ConfigurationHandlerBase在DLL 中的一个类中得到了以下代码:
Protected Function GetCollection(Of TCollection As ConfigurationElementCollection, TSection As …Run Code Online (Sandbox Code Playgroud) double在C#中,我的需求不够精确.我正在写一个分形程序,经过几次放大后,我的精度已经不够了.
我有一个数据类型可以保存比双精度更精确的浮点信息(即更多的小数位)?
我为我的WPF应用程序提供了以下XAML,我将从UWP进行转换:
<ScrollViewer Name="scv_main" Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Auto"
PanningMode="VerticalFirst">
<TextBlock Name="txbl_display" Grid.Row="2" Foreground="White"
FontFamily="Lucida Console" FontSize="22" Text="{Binding Path=ContentPath, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged}" Padding="20" TextWrapping="Wrap"
IsManipulationEnabled="True" ManipulationDelta="manipulationDeltaHandler"/>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
我发现的是,事件处理程序e.IsInertial总是错误的.
我认为可能是ScrollViewer处理惯性事件,但是当我删除ScrollViewer时,我仍然无法获得任何惯性事件.我也尝试将ManipulationDelta放在ScrollViewer上,结果相同.
我的最终目标是我希望ScrollViewer在非惯性移动时滚动,但让我控制惯性滑动时发生的事情.
我在UWP应用程序中管理此效果,我将其移植到WPF,如下所示:
<TextBlock ... ManipulationMode="All" ManipulationDelta="TextBlock_ManipulationDelta/>"
然后在代码隐藏中:
if (e.IsInertial) // inertial = swipe, rather than slide
{
// X-Translation - change contents of textblock
if (e.Cumulative.Translation.X <= -500) //500 is the threshold value, where you want to trigger the swipe right event
{
showNext();
e.Complete();
}
else if (e.Cumulative.Translation.X >= 500)
{
showPrevious();
e.Complete(); …Run Code Online (Sandbox Code Playgroud) 我知道如何创建一个Map<T, List<U>>,使用Collectors.groupingBy:
Map<Key, List<Item>> listMap = items.stream().collect(Collectors.groupingBy(s->s.key));
如何修改要创建的代码Map<Key, Set<Item>>?或者我可以不使用它stream,因此必须使用for循环等手动创建它?
是否可以创建如下所示的基类:
public abstract class baseClass
{
public abstract void SetParameters(/*want this to be adjustable*/);
}
Run Code Online (Sandbox Code Playgroud)
以便覆盖它的类可以定义所需的参数?换句话说,我想强制重写该方法,但是将它留给覆盖类,这里需要什么 - 所以可能是
public class derivedClass1 : baseClass
{
public override void SetParameters(Point a, int b);
}
Run Code Online (Sandbox Code Playgroud)
而另一个可能是
public class derivedClass2 : baseClass
{
public override void SetParameters(List<Line> a, Point b, Point c, bool e);
}
Run Code Online (Sandbox Code Playgroud)
?
谢谢你提供的所有帮助
c# ×5
.net-4.7 ×1
arrays ×1
audio ×1
c#-6.0 ×1
dll ×1
docker ×1
dockerfile ×1
double ×1
grouping ×1
inheritance ×1
java ×1
java-stream ×1
kubernetes ×1
linq ×1
methods ×1
overriding ×1
parameters ×1
precision ×1
set ×1
swipe ×1
types ×1
vb.net ×1
wav ×1
wpf ×1