Using Vorbis and NAudio to play OGG files - c#

I'm trying to play OGG file stream with NVorbis and NAudio, as described in the documention i'm trying to access VorbisWaveReader class, without success, here is my code:
using System;
using System.Collections.Generic;
using System.Text;
using NVorbis;
using NAudio;
namespace Paradise
{
class Program
{
static void Main(string[] args)
{
using (var vorbis = new NVorbis.NAudioSupport.VorbisWaveReader(#"C:\PATH\TO\OGG\FILE.ogg"))
using (var waveOut = new NAudio.Wave.WaveOut())
{
waveOut.Init(vorbis);
waveOut.Play();
}
}
}
}
I'm getting the following error:
type or namespace name 'VorbisWaveReader' does not exist in the namespace 'NVorbis.NAudioSupport'
It looks very basic and should work, i can see in the source code that VorbisWaveReader is present in the code, can you help me go thorugh that?
Thanks!

NVorbis.NAudioSupport change into NAudio.Vorbis
in Package-Manager Console type this:
Install-Package NAudio.Vorbis

Related

Windows.Storage error: the type of namespace Storage does not exist in namespace windows

I am very new to C#, visual studio, and related Microsoft work. So it is very likely that I messed something up and I hope some one can help me a bit on this.
I create an Console application and I am trying to run some tutorial C# code. There is a red line under when I try to load Windos.Storage.Pickers and all namespaces after it. I attempt to add the references, but I can't find what I need there.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows;
using Windows.Storage.Pickers;
using Windows.Storage.Streams;
using Windows.Graphics.Imaging;
using Windows.Media.FaceAnalysis;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Shapes;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
FaceDetector faceDetector;
IList<DetectedFace> detectedFaces;
FileOpenPicker photoPicker = new FileOpenPicker();
photoPicker.ViewMode = PickerViewMode.Thumbnail;
photoPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
photoPicker.FileTypeFilter.Add(".jpg");
photoPicker.FileTypeFilter.Add(".jpeg");
photoPicker.FileTypeFilter.Add(".png");
photoPicker.FileTypeFilter.Add(".bmp");
StorageFile photoFile = await photoPicker.PickSingleFileAsync();
if (photoFile == null)
{
return;
}
}
}
}
the namespace you are tying to use is use for UWP development.
The problem is that you are trying to use it in Console Development.
Read about it here

How to pass a filename/path to text parser

I'm trying to get a simple text parser class to work in VS2015. I received the class code and built a basic Console Application, added the class Cawk and tried to compile/run it.
The main error that I get is
Argument 1: cannot convert from 'string' to 'System.IO.StreamReader'
It's clear that I can't figure out how to pass a filename through Main to Cawk. How do I give it an argument of a filename?
Any help or pointers would be appreciated.
My Program.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main()
{
string input = #"c:\temp\test.txt";
Cawk.Execute(input);
}
}
}
Snippet of My Cawk.cs:
using System;
using System.Collections.Generic;
using System.IO;
namespace ConsoleApplication3
{
public static class Cawk
{
public static IEnumerable<Dictionary<string, object>> Execute(StreamReader input)
{
Dictionary<string, object> row = new Dictionary<string, object>();
string line;
//string[] lines = File.ReadAllLines(path);
//read all rows
while ((line = input.ReadLine()) != null)
{
Execute accepts a StreamReader not a string.
Cawk.Execute(new StreamReader(#"c:\temp\test.txt"))
However, you should close the stream after you are done with it.
using (var sr = new StreamReader(#"c:\temp\test.txt"))
{
Cawk.Execute(sr);
}
something like:
var sr = new System.IO.StreamReader(#"c:\temp\test.txt");
Cawk.Execute(sr);
Simply use the File class from the System.IO namespace.
Cawk.Execute(File.OpenText(#"c:\temp\test.txt"));
Like this:
string input = #"c:\temp\test.txt";
Cawk.Execute(new System.IO.StreamReader(input));
You can put using System.IO; to the top like the rest of the usings, then you don't have to write it out later.

How to print out the result of a SWI-Prolog query from C# using Swi-cs-pl library

I'm trying to understand how the Swi-cs-pl library works by doing my own little program, but I cannot printout any result from a query based on the example from SWI-Prolog web.
I have this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SbsSW.SwiPlCs;
namespace HolaMundo
{
class Program
{
static void Main(string[] args)
{
if (!PlEngine.IsInitialized)
{
String[] param = { "-q" }; // suppressing informational and banner messages
PlEngine.Initialize(param);
PlQuery.PlCall("assert(father(hader, nevar))");
PlQuery.PlCall("assert(father(hader, sergio))");
PlQuery.PlCall("assert(brother(nevar, sergio):- father(hader, nevar), father(hader, sergio))");
//How do I write out in a Console the answer for a query like:
// brother(nevar, sergio)
PlEngine.PlCleanup();
}
}
}
}
As I said on my code, I just want to query something basic like: brother(nevar, sergio). and get any answer from Console like true or whatever.
Can anyone help me?

FTP C# console 2010 sending data.dat file of 71kb i get a file in my ftp but it is 0byte

okay so basically I am using the class object from here
http://www.codeproject.com/Tips/443588/Simple-Csharp-FTP-Class
I have then created my main program file here it is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
/* Create Object Instance */
ftp ftpClient = new ftp(#"ftp://ftp.drivehq.com/", "ashg1990", "Robert12");
/* Upload a File */
ftpClient.upload("stat.dat", #"C:\Users\ash\AppData\Roaming\EruptMiner\Stats.dat");
}
}
}
this code works to a degree but the file I get is a 0byte one so it not the original and is blank can any one help me

LinkFinder.find fails to work in webcrawler app

Wrote code as the start to a web crawler that scrapes links from webpage.
Following the instructions from this page:
http://www.dotnetperls.com/scraping-html
I seem to get an error that LinkFinder cannot be found?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Diagnostics;
namespace WebCrawler
{
class Program
{
static void Main(string[] args)
{
WebClient url = new WebClient();
String initialLink = url.DownloadString("http://www.FAKEADDRESS.org.uk/");
for (LinkItem i in LinkFinder.find(initialLink))
{
System.Diagnostics.Debug.WriteLine(initialLink);
}
}
}
}
LinkFinder is a class that is included in the code at that URL you provided. Make sure you also copy that class into your project in some way (a file by itself, in another file, whatever).

Categories

Resources