Это код С# в подарок на ДР.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NAudio;
using NAudio.Wave;
using System.IO;
using System.Windows;
using System.Diagnostics;
namespace SoundNumber
{
public partial class Form1 : Form
{
static string cont = "_";
static string dirm="";
static List<string> stl = new List<string>();
static char, number ={{'0','0','0'},
{'0','0','0'},
{'0','0','0'},
{'0','0','0'},};
IWavePlayer waveOutDevice;
AudioFileReader audioFileReader;
public Form1()
{
InitializeComponent();
}
static bool provTxt(string str)
{
int k = 0;
if (str0 == '0' && str.Length > 1) return False;
for (int i = 0; i < str.Length; i++)
if (((int)stri >= 48 && (int)stri <= 57)) k+=1 ;
else return False;
if (k > 12) return False;
return True;
}
static string dirw = "";
public static string SoftwareDir
{
get
{
return Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
}
}
public static bool Normalize(string wavFile)
{
ProcessStartInfo info = new ProcessStartInfo(Path.Combine(SoftwareDir, "normalize.exe"))
{
Arguments = String.Format("\"{0}\"", wavFile),
CreateNoWindow = True,
UseShellExecute = False
};
try
{
using (Process process = Process.Start(info))
{
process.WaitForExit();
}
return True;
}
catch (Exception)
{
return False;
}
}
public static bool Mp3ToWav(string mp3File, string outwavFile)
{
try
{
using (Mp3FileReader reader = new Mp3FileReader(mp3File))
{
// ImpulseResponseConvolution filt = new ImpulseResponseConvolution();
using (WaveStream pcmStream = new WaveFormatConversionStream(new WaveFormat(44100, 16, 2), reader))
{
WaveFileWriter.CreateWaveFile(outwavFile, pcmStream);
}
Normalize(outwavFile);
}
return True;
}
catch (Exception)
{
return False;
}
}
private void button1_Click(object sender, EventArgs e)
{
string numbsen=textBox1.Text;
if (provTxt(numbsen))
{
DisposeAudio();
if (File.Exists(dirm))
File.Delete(dirm);
stl.Clear();
dirm = Environment.CurrentDirectory + "\\" + numbsen + ".mp3";
dirw = Environment.CurrentDirectory + "\\" + numbsen + ".wav";
if (numbsen.CompareTo("0") == 0)
stl.Add("_0");
else
SelNumber(numbsen);
Combine(stl, new FileStream(dirm, FileMode.Create));
Mp3ToWav(dirm, dirw);
this.Text = "Сохранено в: " + dirm;
//waveOutDevice = new WaveOut();
//audioFileReader = new AudioFileReader(dirm);
//waveOutDevice.Init(audioFileReader);
//waveOutDevice.Play();
}
else
{
MessageBox.Show("это же синтезатор числа а не общий синтезатор.))))\n"+
"Или вы вели число не кому не нужное)))))");
}
}
private void DisposeAudio()
{
if (waveOutDevice != None)
{
waveOutDevice.Stop();
}
if (waveOutDevice != None)
{
if (audioFileReader != None)
{
audioFileReader.Dispose();
audioFileReader = None;
}
waveOutDevice.Dispose();
waveOutDevice = None;
}
}
public static void Concatenate(string outputFile, string wav1, string wav2)
{
byte buffer = new byte1024;
WaveFileWriter waveFileWriter = None;
List<string> wavelist = new List<string>();
wavelist.Add(wav1); wavelist.Add(wav2);
try
{
foreach (string sourceFile in wavelist)
{
using (WaveFileReader reader = new WaveFileReader(sourceFile))
{
if (waveFileWriter == None)
{
// first time in create new Writer
waveFileWriter = new WaveFileWriter(outputFile, reader.WaveFormat);
}
int read;
while ((read = reader.Read(buffer, 0, buffer.Length)) > 0)
{
waveFileWriter.Write(buffer, 0, read);
}
}
}
}
finally
{
if (waveFileWriter != None)
{
waveFileWriter.Dispose();
}
}
}
/* public static bool FileMerge(string wav1,string wav2,string outwav)
{
const int BufferSize = 16384;
byte buffer = new byteBufferSize;
int bytesCopied = 0;
try
{
using (FileStream wav1stream = File.Open(
wav1, FileMode.Open,
FileAccess.Read, FileShare.Read))
using (FileStream wav2stream = File.Open(
wav2, FileMode.Open,
FileAccess.Read, FileShare.Read))
{
do
{
bytesCopied = wav2stream.Read(buffer, 0, BufferSize);
if (bytesCopied > 0)
{
wav1stream.Write(buffer, 0, bytesCopied);
}
} while (bytesCopied > 0);
}
}
catch
{
return False;
}
return True;
}
public static void Mp3Merge2(string mp31,string mp32, Stream output)
{
Mp3FileReader reader = new Mp3FileReader(mp31);
Mp3Frame frame;
while ((frame = reader.ReadNextFrame()) != None)
{
output.Write(frame.RawData, 0, frame.RawData.Length);
}
reader = new Mp3FileReader(mp32);
while ((frame = reader.ReadNextFrame()) != None)
{
output.Write(frame.RawData, 0, frame.RawData.Length);
}
output.Close();
}*/
public static void Combine(List<string> inputFiles, Stream output)
{
foreach (string file in inputFiles)
{
byte b =
(byte)SoundNumber.Properties.Resources.ResourceManager.GetObject(file);
if (b != None)
{
output.Write(b, 0, b.Length);
}
}
output.Close();
}
static void SelNumber(string ln)
{
for (int i = 0; i < 4; i++)
for (int j = 0; j < 3; j++)
numberi, j = '0';
int leng = ln.Length;
for (int i = 0; i < leng; i++)
{
int nt = leng - i;
switch (nt)
{
case 12:
if ((int)lni != 48)
{
number0, 0 = lni;
stl.Add(cont + lni + "00" );
}
break;
case 11:
if (lni != '1')
{
if ((int)lni != 48)
{
number1, 1 = lni;
stl.Add(cont + lni + "0" );
}
}
else
{
number0, 1 = lni;
stl.Add(cont + lni + lni + 1 );
stl.Add(cont + "1000000000" );
i++;
}
break;
case 10:
if ((int)lni != 48)
{
number0, 2 = lni;
if (number0, 0 == '0' && number0, 1 == '0' && lni == '1')
stl.Add(cont + "1000000001" );
else if (lni == '2' || lni == '3' || lni == '4')
{
stl.Add(cont + lni );
stl.Add(cont + "1000000000a");
}
else
{
stl.Add(cont + lni );
stl.Add(cont + "1000000000ov" );
}
}
else
{
stl.Add(cont + "1000000000" );
}
break;
case 9:
if ((int)lni != 48)
{
number1, 0 = lni;
stl.Add(cont + lni + "00");
}
break;
case 8:
if (lni != '1')
{
if ((int)lni !=48)
{
number1, 1 = lni;
stl.Add(cont + lni + "0");
}
}
else
{
number1, 1 = lni;
stl.Add(cont + lni + lni + 1 );
stl.Add(cont + "1000000" );
i++;
}
break;
case 7:
if (lni != '0')
{
number1, 2 = lni;
int nk=0;
for (int k = 0; k < 3;k++ )
if (number0, k != '0') nk += 1;
if (lni == '1' && number1,0=='0' && number1,1=='0' && nk==0)
stl.Add(cont + "1000000ov" );
else if (lni == '1')
{
stl.Add(cont + lni);
stl.Add(cont + "1000000ov");
}
else if (lni == '2' || lni == '3' || lni == '4')
{
stl.Add(cont + lni);
stl.Add(cont + "1000000a");
}
else
{
stl.Add(cont + lni);
stl.Add(cont + "1000000");
}
}
else
{
if(number1, 0 != '0' || number1, 1 != '0')
stl.Add(cont + "1000000");
}
break;
case 6:
if ((int)lni != 48)
{
number2, 0 = lni;
stl.Add(cont + lni + "00");
}
break;
case 5:
if (lni != '1')
{
if ((int)lni != 48)
{
number2, 1 = lni;
stl.Add(cont + lni + "0");
}
}
else
{
number2, 1 = lni;
stl.Add(cont + lni + lni + 1 );
stl.Add(cont + "1000" );
i++;
}
break;
case 4:
if ((int)lni != 48)
{
number2, 2 = lni;
if(number2,0=='0' && number2,1=='0' && lni=='1')
stl.Add(cont + "1001" );
else if (lni == '2')
{
stl.Add(cont + "2e");
stl.Add(cont + "1000i");
}
else if (lni == '3' || lni == '4')
{
stl.Add(cont + lni);
stl.Add(cont + "1000i");
}
else if (lni == '1')
{
stl.Add(cont + lni + "a" );
stl.Add(cont + "1001" );
}
else
{
stl.Add(cont + lni );
stl.Add(cont + "1000" );
}
}
else
{
if (number2, 0 != '0' || number2, 1 != '0')
stl.Add(cont + "1000");
}
break;
case 3:
if ((int)lni != 48)