[英]Binary to .Beep Method in c#
Hey im trying to do something a little bit different, that is to convert a string to binary then to convert binary to a low pitch for 0 and a high pitch for a 1. However im completely lost on how to do so i was thinking of using .Beep Here is the code: 嘿,我尝试做一些不同的事情,就是将字符串转换为二进制,然后将二进制转换为0的低音高和1的高音。但是我完全不知道该怎么做。使用.Beep这是代码:
using System;
using System.Linq;
using System.Text;
namespace SoundHyperLink
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("imput url ");
string stringImput = Console.ReadLine();
string BinaryString = (ToBinaryString(Encoding.UTF8, stringImput));
Console.WriteLine(BinaryString);
Console.ReadLine();
}
static string ToBinaryString(Encoding encoding, string text)
{
return string.Join("", encoding.GetBytes(text).Select(n => Convert.ToString(n, 2).PadLeft(8, '0')));
}
public void ToSoundString(string message)
{
}
If anyone could help me i would be supper happy as i cant find anything on the internet for this 如果有人可以帮助我,我将非常高兴,因为我在互联网上找不到任何东西
Define one frequency for each 0 and 1 and use it like this : 为每个0和1定义一个频率,并像这样使用它:
static void Main(string[] args)
{
Console.WriteLine("imput url ");
string stringImput = Console.ReadLine();
string BinaryString = (ToBinaryString(Encoding.UTF8, stringImput));
Console.WriteLine(BinaryString);
ToSoundString(BinaryString);
Console.ReadLine();
}
static string ToBinaryString(Encoding encoding, string text)
{
return string.Join("", encoding.GetBytes(text).Select(n => Convert.ToString(n, 2).PadLeft(8, '0')));
}
public static void ToSoundString(string message)
{
message.ToList().ForEach(f =>
{
switch (f)
{
case '0':
Console.Beep(500, 100);
break;
case '1':
Console.Beep(800, 100);
break;
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.